python 操作clickhouse

pip install clickhouse
pip install clickhouse_driver

from clickhouse_driver import Client

clickhouse_user = 'name'
clickhouse_pwd = 'pass'
clickhouse_host_sq = 'ip'
clickhouse_database = 'db'
begin_time='2019-05-06'
end_time='2019-05-12'
client = Client(host=clickhouse_host_sq,user=clickhouse_user ,
database=clickhouse_database, password=clickhouse_pwd)
api_interface_sql = "select accountName,count(*) as count,sum(backendTime) as sum from logs "
"where date>='{}' and date<='{}' and appName = 'service_si_new' and backendName != '' group by accountName order by count desc limit 0,10"
.format(begin_time,end_time)
try:
a=client.execute(api_interface_sql)
print(a)
except Exception as e:
print(e)

你可能感兴趣的:(python 操作clickhouse)