from aiochclient import ChClient
from aiohttp import ClientSession
# create connection to wsprlive clickhouse server
s = ClientSession()
client = ChClient(s, url="https://db1.wspr.live")
# check connection state
if not await client.is_alive():
print("database conneciton failed!")
else:
print("database ready")
# fetch data
all_rows = await client.fetch("SELECT anyLast(time) as t, count(*) as spots "\
"FROM wspr.rx "\
"WHERE time > '2010-01-01' "\
"GROUP BY toYYYYMM(time) ORDER BY t")
# print result info
print("got %i lines back"%len(all_rows))
import pandas as pd
# convert list or rows to table
dd = pd.DataFrame(all_rows)
import matplotlib.pyplot as plt
# plot data using matplotlib
plt.plot("t", "spots", data=dd);