安装
pip install clickhouse-driver
测试
clickhouse插入数据
create table t1 (id UInt16, name String) ENGINE=TinyLog;
insert into t1(id, name) values (1, ‘first’);
代码测试
##查询
from clickhouse_driver import Client
client = Client(host=‘clickhouse’,port=‘9000’)
sql = “select * from t1”
ans = client.execute(sql)
ans
[(1, ‘first’)]
##插入sql2 = “insert into t1(id, name) values (2, ‘first’)”
ans = client.execute(sql2)