0
from clickhouse_driver import Client
client = Client(host = 'user',port=8123)
import csv
with open('/home/user/Desktop/customer_df.csv') as csvfile:
    reader = csv.reader(csvfile)
    for row in reader:
        client.execute('INSERT INTO custmer VALUES',[row])

Failed to connect to user:8123
Traceback (most recent call last):
  File "/home/user/anaconda3/lib/python3.9/site-packages/clickhouse_driver/connection.py", line 342, in connect
    return self._init_connection(host, port)
  File "/home/user/anaconda3/lib/python3.9/site-packages/clickhouse_driver/connection.py", line 306, in _init_connection
    self.socket = self._create_socket(host, port)
  File "/home/user/anaconda3/lib/python3.9/site-packages/clickhouse_driver/connection.py", line 278, in _create_socket
    raise err
  File "/home/user/anaconda3/lib/python3.9/site-packages/clickhouse_driver/connection.py", line 269, in _create_socket
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

How to check port of my clickhouse and I dont know where its wrong in the code

1

1 Answer 1

1

clickhouse-driver uses the native protocol. By default the ClickHouse server listens on port 9000 (or port 9440 for TLS), and there's not usually a reason to change it.

You can check your config.xml file for port numbers. The setting for the TCP port is documented here https://clickhouse.com/docs/en/operations/server-configuration-parameters/settings#server_configuration_parameters-tcp_port.

Other clients, such as JDBC or the Python clickhouse-connect client, use the HTTP port, which is why you often see 8123 (8443 for HTTPS).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.