python連接clickhouse的端口問(wèn)題及解決
python連接clickhouse端口問(wèn)題
<!-- 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>注意到可以使用兩個(gè)端口,8123 和 9000 分別接收 http 協(xié)議和tcp協(xié)議。
- 如果用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()此時(shí)如果用8123端口則會(huì)得到如下報(bào)錯(cuò):
clickhouse_driver.errors.UnexpectedPacketFromServerError: Code: 102. Unexpected packet from server 192.168.137.101:8123 (expected Hello or Exception, got Unknown packet)
向clickhouse導(dǎo)數(shù)據(jù)報(bào)錯(cuò)
clickhouse_driver.errors.UnexpectedPacketFromServerError: Code: 102
今天用python寫(xiě)個(gè)etl從mysql向clickhouse同步數(shù)據(jù), 數(shù)據(jù)量不到1千萬(wàn),導(dǎo)了一會(huì)報(bào)上面的第錯(cuò)誤。然后在網(wǎng)上查了一下:找到文檔寫(xiě)得很清楚:
Welcome to clickhouse-driver — clickhouse-driver 0.2.4 documentation
原來(lái)clickhouse提供兩個(gè)端口:8123和9000
用native protocal需要使用9000端口,然后修改端口后成功。
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Python中自然語(yǔ)言處理和文本挖掘的常規(guī)操作詳解
自然語(yǔ)言處理和文本挖掘是數(shù)據(jù)科學(xué)中的重要領(lǐng)域,涉及對(duì)文本數(shù)據(jù)的分析和處理,這篇文章為大家介紹了一些常見(jiàn)的任務(wù)和實(shí)現(xiàn)方法,需要的可以了解下2025-02-02
python merge、concat合并數(shù)據(jù)集的實(shí)例講解
下面小編就為大家分享一篇python merge、concat合并數(shù)據(jù)集的實(shí)例講解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-04-04
python PyQt5/Pyside2 按鈕右擊菜單實(shí)例代碼
本文通過(guò)實(shí)例代碼給大家介紹了python PyQt5/Pyside2 按鈕右擊菜單,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2019-08-08
Python 中使用 Selenium 單擊網(wǎng)頁(yè)按鈕功能
Selenium是一個(gè)用于測(cè)試網(wǎng)站的自動(dòng)化測(cè)試工具,支持各種瀏覽器包括Chrome、Firefox、Safari等主流界面瀏覽器,同時(shí)也支持phantomJS無(wú)界面瀏覽器,本篇文章將介紹如何在 Python 中使用 selenium 單擊網(wǎng)頁(yè)上的按鈕,感興趣的朋友一起看看吧2023-11-11
Python如何聲明以管理員方式運(yùn)行(附實(shí)戰(zhàn)案例)
由于Windows的安全機(jī)制,Python寫(xiě)的腳本缺少了管理員權(quán)限,運(yùn)行就會(huì)受到一些限制,這篇文章主要介紹了Python如何聲明以管理員方式運(yùn)行的相關(guān)資料,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下2025-04-04
淺談Python對(duì)內(nèi)存的使用(深淺拷貝)
這篇文章主要介紹了淺談Python對(duì)內(nèi)存的使用(深淺拷貝),具有一定借鑒價(jià)值,需要的朋友可以參考下2018-01-01

