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 Client

client = Client(
    host = '192.168.56.16',
    port = '9000', # 或 9000
    user = 'acai',
    password = '123456@abc.COM',
    database = 'default'
)
def test():
    global client
    sql = 'show tables' # show databases;
    res = client.execute(sql)
    print(res)

if __name__ == '__main__':
    test()
相关推荐
4t4run8 天前
1、clickhouse 安装
数据库·clickhouse
JackSparrow4149 天前
使用Elasticsearch代替数据库like以加快查询的各种技术方案+实现细节
大数据·clickhouse·elk·elasticsearch·搜索引擎·postgresql·全文检索
梦想与想象-广州大智汇16 天前
MySQL 同步数据到 ClickHouse 方案对比分析
数据库·mysql·clickhouse
Smile_25422041816 天前
clickhouse日志疯涨问题
linux·运维·服务器·clickhouse
计算机魔术师17 天前
【技术硬核 | 存储】ClickHouse 原理与 Langfuse 存储实践:当 LLM Trace 爆炸时,PG 还扛得住吗?
人工智能·clickhouse·工程实践·sbti·职场焦虑
fire-flyer20 天前
ClickHouse系列(九):慢查询、内存 OOM 与稳定性治理
android·clickhouse
fire-flyer20 天前
ClickHouse系列(十):生产架构与最佳实践总结
clickhouse·架构
fire-flyer20 天前
ClickHouse系列(八):ClickHouse 的 UPDATE / DELETE 正确姿势
大数据·数据库·clickhouse
fire-flyer20 天前
ClickHouse系列(七):Materialized View 与多分辨率 Rollup 设计
大数据·数据库·clickhouse·架构
fire-flyer22 天前
ClickHouse系列(二):MergeTree 家族详解
大数据·数据库·clickhouse