Connecting to ClickHouse with Python

In this example we will show how you can use the official Python driver for ClickHouse to connect to your cluster. Before you begin, it is imperative to review the general steps and considerations for connecting to a ClickHouse cluster as outlined in Connecting to a ClickHouse Cluster. 

1. Install the clickhouse-connect driver for Python. You can either use the pip command or can download it from GitHub. For detailed installation instructions see https://github.com/ClickHouse/clickhouse-docs/blob/main/docs/en/integrations/language-clients/python/index.md

or

2. Gather the host domain name and password for the icclickhouse user from the Connection Info page on console.

3. Replace them into the following script and you should be good to connect to your cluster.