python连接clickhouse端口报错怎么解决
本篇内容介绍了“python连接clickhouse端口报错怎么解决”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
python连接clickhouse端口问题
<!-- It is the name that will be shown in the clickhouse-client. By default, anything with "production" will be highlighted in red in query prompt. --> <!--display_name>production</display_name--> <!-- Port for HTTP API. See also 'https_port' for secure connections. This interface is also used by ODBC and JDBC drivers (DataGrip, Dbeaver, ...) and by most of web interfaces (embedded UI, Grafana, Redash, ...). --> <http_port>8123</http_port> <!-- Port for interaction by native protocol with: - clickhouse-client and other native ClickHouse tools (clickhouse-benchmark, clickhouse-copier); - clickhouse-server with other clickhouse-servers for distributed query processing; - ClickHouse drivers and applications supporting native protocol (this protocol is also informally called as "the TCP protocol"); See also 'tcp_port_secure' for secure connections. --> <tcp_port>9000</tcp_port>
注意到可以使用两个端口,8123 和 9000 分别接收 http 协议和tcp协议。
如果用jdbc连接,端口为 8123
如果用driver连接,端口为 9000
from clickhouse_driver import Clientclient = 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端口,然后修改端口后成功。
“python连接clickhouse端口报错怎么解决”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注编程网网站,小编将为大家输出更多高质量的实用文章!
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341