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()
相关推荐
IT油腻大叔2 天前
MySQL VS ClickHouse 索引结构对比分析
mysql·clickhouse
-KamMinG2 天前
解决 ClickHouse 备份性能问题:从原生 BACKUP 迁移到 clickhouse-backup 的实战经验
clickhouse
2301_807583236 天前
ubuntu22.04集群部署clickhouse详细步骤
linux·clickhouse·zookeeper
Azure++8 天前
Centos安装clickhouse
linux·clickhouse·centos
阳爱铭11 天前
ClickHouse 中至关重要的两类复制表引擎——ReplicatedMergeTree和 ReplicatedReplacingMergeTree
大数据·hive·hadoop·sql·clickhouse·spark·hbase
liao__ran16 天前
ClickHouse CPU 排查快速参考指南
运维·服务器·clickhouse
XueminXu16 天前
ClickHouse查看数据库、表、列等元数据信息
clickhouse·system·元数据·databases·system.tables·system.columns·system.settings
liao__ran16 天前
ClickHouse CPU 排查详细指南
运维·clickhouse
现在,此刻17 天前
高可用与高性能数据库配置实践分析(pgSql && clickhouse)
数据库·clickhouse
yourkin66618 天前
clickhouse
clickhouse