from settings import cassandra_addresses, cassandra_port, setup_db_dir, setup_tables_dir from cassandra.cluster import Cluster import os print(" == DB SETUP SCRIPT == ") print(f"Attempting Cassandra connection @ {cassandra_addresses}:{cassandra_port}") cluster = Cluster(cassandra_addresses, port=cassandra_port) session = cluster.connect() print(f"Connection OK") with open(f"{setup_db_dir}/keyspace/CREATE.sql") as keyspace_create: session.execute(keyspace_create.read()) with open(f"{setup_db_dir}/keyspace/USE.sql") as keyspace_use: session.execute(keyspace_use.read()) for folder_name in os.listdir(setup_tables_dir): with open(f'{setup_tables_dir}/{folder_name}/CREATE.sql') as sql_create: session.execute(sql_create.read()) session.execute("INSERT INTO transactions (tx_id,address,value,tx_hash,block_id,timestamp) VALUES(1697,'t1KmCvfPMgfQXeNosFqzAmvYdEoYfdnxnVA',15701,'18c23345908f5097456c5f0014411381fd9866790aa65b863aab24ee17453732',818,1477724947)") res = session.execute('SELECT * FROM transactions') print(res.one())