Fork me on GitHub

clickhouse的python库:clickhouse-driver使用

安装

1
pip install clickhouse-driver

导入

1
from clickhouse_driver import Client

连接

1
2
3
import clickhouse_driver
client = clickhouse_driver.Client(host='localhost', port='9000', database='xxx', user='default', password='xxx')

创建表

1
client.execute('create table aaa(id Int8,name Stinrg) ENGINE = Memory')

查询

1
2
for id in client.execute('SELECT id,name FROM aaa limit 20'):
print(id)

添加插入

1
client.execute("""insert into aaa (id,name) VALUES""", [(1, 'lwg')])

禹都一只猫,热爱IT,支持原创