安装

pip install clickhouse-driver

测试

clickhouse插入数据
create table t1 (id UInt16, name String) ENGINE=TinyLog;
insert into t1(id, name) values (1, ‘first’);
python使用clickhouse
代码测试
##查询

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)
python使用clickhouse

相关文章: