本文主要是介绍python连接clickhouse (CK),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
'''
Author: tkhywang 2810248865@qq.com
Date: 2023-11-01 11:28:58
LastEditors: tkhywang 2810248865@qq.com
LastEditTime: 2023-11-01 11:36:25
FilePath: \PythonProject02\Python读取clickhouse2 数据库数据.py
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
'''# 注意代码中是clickhouse_driver,而pip安装包是clickhouse-driver。因为python代码习惯用下划线
from clickhouse_driver import Clientclient = Client(host = '192.168.56.16',port = '9000', # 或 9000user = 'acai',password = '123456@abc.COM',database = 'default'
)
def test():global clientsql = 'show tables' # show databases;res = client.execute(sql)print(res)if __name__ == '__main__':test()
这篇关于python连接clickhouse (CK)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!