python clickhouse的安装及简单使用
1、clickhouse的安装
pip install clickhouse_driver
2、client连接
from clickhouse_driver import Client client = Client(host='127.0.0.1', port='9000', user="root", password="123456") # 连接数据库 sql = "insert into xxx" client.execute(sql) # 执行语句
3、connect方法
conn = connect(dsn=None, host=None, user=defines.DEFAULT_USER, password=defines.DEFAULT_PASSWORD, port=defines.DEFAULT_PORT, database=defines.DEFAULT_DATABASE, **kwargs) cursor = conn.cursor() sql = "xxxx" res = cursor.execute(sql) cursor.close()