-
Notifications
You must be signed in to change notification settings - Fork 0
/
query-cluster.py
32 lines (26 loc) · 892 Bytes
/
query-cluster.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from clickhouse_driver import Client
subs = [
("127.0.0.1", "9001"),
("127.0.0.1", "9002"),
("127.0.0.1", "9003"),
("127.0.0.1", "9004")
]
master = ("127.0.0.1", "9000")
def print_data(data):
for row in data:
print("Timestamp", row[0], sep=": ")
print("Parameter", row[1], sep=": ")
print("Value", row[2], sep=": ")
print()
if __name__ == "__main__":
for sub in subs:
client = Client(sub[0], port=sub[1])
# data = client.execute("SELECT * FROM db.entries")
data = client.execute("SELECT * FROM billing.transactions")
print("SUB port:", sub[1])
print_data(data)
client = Client(master[0], port=master[1])
# data = client.execute("SELECT * FROM db.entries")
data = client.execute("SELECT * FROM billing.transactions")
print("MASTER port:", master[1])
print_data(data)