DB Connection from Python code

Connecting ChistaDATA database from Python code

Python is a high-level, general-purpose programming language and we can connect to ClickHouse from Python via package called pip install clickhouse-driver.

PyPi - Official PyPi page Doc - Official Documentation


  1. Create a Client object
from clickhouse_driver import Client

client = Client(host='ws39-ch60.db.chistadata.io', user='default', password='******', port='9440', 
                                send_receive_timeout=600, secure=True )
  1. Execute a query
databases = client.execute('SHOW DATABASES')
  1. Disconnect from the Database