您现在的位置是:网站首页> 编程资料编程资料
python连接clickhouse的端口问题及解决_python_
2023-05-26
329人已围观
简介 python连接clickhouse的端口问题及解决_python_
python连接clickhouse端口问题
8123 9000
注意到可以使用两个端口,8123 和 9000 分别接收 http 协议和tcp协议。
- 如果用jdbc连接,端口为 8123
- 如果用driver连接,端口为 9000
from clickhouse_driver import Client client = Client(host=host, port=port, user=user, password=password, database='default') client = get_client() client.execute("show tables;") print(client.execute("select * from test_arr")) client.disconnect()此时如果用8123端口则会得到如下报错:
clickhouse_driver.errors.UnexpectedPacketFromServerError: Code: 102. Unexpected packet from server 192.168.137.101:8123 (expected Hello or Exception, got Unknown packet)
向clickhouse导数据报错
clickhouse_driver.errors.UnexpectedPacketFromServerError: Code: 102
今天用python写个etl从mysql向clickhouse同步数据, 数据量不到1千万,导了一会报上面的第错误。然后在网上查了一下:找到文档写得很清楚:
Welcome to clickhouse-driver — clickhouse-driver 0.2.4 documentation
原来clickhouse提供两个端口:8123和9000
用native protocal需要使用9000端口,然后修改端口后成功。
以上为个人经验,希望能给大家一个参考,也希望大家多多支持。
您可能感兴趣的文章:
