clickhouse_driver.errors.UnexpectedPacketFromServerError:代码:102。来自服务器的意外数据包无:无

Erg*_*uzi 11 python python-3.9

我正在尝试连接 clickhouse_driver
\n=> python3.9
\n=>clickhouse_driver-0.2.1

\n
\n

\xe3\x80\x90error\xe3\x80\x91clickhouse_driver.errors.UnexpectedPacketFromServerError:代码:102。来自服务器的意外数据包无:无(预期的 Hello 或异常,收到未知数​​据包)
\n\xe3\x80\x90DataGrip\xe3\x80 \x91在 DataGrip 上使用正常

\n
\n
class ClickHouse(DB_BASE):\n    _user = 'default'\n    _pass = 'ddfc272d99a308192ec5961f06133b14b56d2d89ae70ecb02d4acf40d21d1692'\n    elec_database = 'test'\n    send_receive_timeout = 20000\n\n    def db_connection(self):\n        connectConf = {'host': '127.0.0.1', 'port': 8123, 'user': self._user, 'password': self._pass,\n                       'send_receive_timeout': self.send_receive_timeout}\n        conn = Client(**connectConf)\n        sqlSentence = 'show databases'\n        rows = conn.execute(sqlSentence)\n
Run Code Online (Sandbox Code Playgroud)\n

小智 13

ClickHouse服务器提供两种通信协议:

  • HTTP协议(默认端口8123);
  • 本机 (TCP) 协议(默认端口 9000)。

Clickhouse-driver 旨在通过本机协议从 Python与 ClickHouse 服务器进行通信。

参考: https: //clickhouse-driver.readthedocs.io/en/latest/

因此,如果您从Python(通过本机协议)访问ClickHouse服务器,您应该将8123端口切换到9000端口。