1234567891011121314151617181920212223242526272829 |
- import time
- import sys
- import json
- from typing import Dict
- from cassandra.cluster import Cluster
-
- sys.path.append("config/db")
-
- config = json.load(open("./settings.json"))
-
- print(
- f"Attempting Cassandra connection @ {config['cassandra_addresses']}:{config['cassandra_port']}")
- cluster = Cluster(config['cassandra_addresses'],
- port=config['cassandra_port'])
- session = cluster.connect(config['cassandra_keyspace'])
- print(f"Connection OK")
-
- result = session.execute("SELECT * FROM clusters")
-
- map = dict()
-
- for e in result.all():
- if(e[1] not in map):
- map[e[1]] = []
-
- map[e[1]].append(e[0])
-
- for key in map:
- print(sorted(map[key]))
|