from settings import cassandra_addresses, cassandra_port, cassandra_keyspace, setup_tables_dir, setup_db_dir from cassandra.cluster import Cluster import os print(" == DB TEARDOWN SCRIPT == ") print(f"Attempting Cassandra connection @ {cassandra_addresses}:{cassandra_port}") cluster = Cluster(cassandra_addresses, port=cassandra_port) session = cluster.connect(cassandra_keyspace) print(f"Connection OK") for folder_name in os.listdir(setup_tables_dir): print(f"Dropping table {folder_name}") with open(f'{setup_tables_dir}/{folder_name}/DROP.sql') as sql_drop: session.execute(sql_drop.read()) with open(f"{setup_db_dir}/keyspace/DROP.sql") as keyspace_create: print(f"Dropping keyspace {cassandra_keyspace}") session.execute(keyspace_create.read()) print("Done!")