---
url: /v6.2/en-us/connecting-clickhouse.md
---
# Connecting to ClickHouse

### Connection Steps

Please follow the steps below to connect to the `ClickHouse` data source.

1. Click "New Data Connection" in the upper right corner of the data connection page.
   ![](/images/data-connection/connection-001.png)

2. Select the `ClickHouse` data source from the data source types.
   ![](/images/data-connection/connecting-clickhouse-001.png)

3. Fill in the required parameters for the data source connection as prompted.
   ![](/images/data-connection/connecting-clickhouse-002.png)

   **Connection Configuration Information Description**

   | Field                                  | Description                                                                                                                |
   | --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
   | Name                                   | The name of the connection. Required and unique within the user.                                                           |
   | Host                                   | The address of the database. If the URL field is filled in, the URL will take precedence.                                 |
   | Port                                   | The port of the database. If the URL field is filled in, the URL will take precedence.                                    |
   | Username                               | The username for the database.                                                                                            |
   | Password                               | The password for the database.                                                                                            |
   | Database                               | The name of the database.                                                                                                 |
   | Max Connections                        | The maximum number of connections in the connection pool.                                                                 |
   | Encoding                               | The encoding setting for the database connection.                                                                         |
   | Prefer using database comment as dataset title | Prefer to display the table name or the table comment.                                                            |
   | URL                                    | The JDBC URL of the database.                                                                                             |
   | Cluster                                | For output only. Output to the specified cluster. If this parameter is empty, only the local MergeTree table is written. If filled, a distributed table will be generated based on the local MergeTree table according to the cluster. |
   | Use Table Replicas for ClickHouse Output| For output only. Whether to use table replicas. If not using replicas, the table engine is MergeTree; if using replicas, the table engine is ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/{table}/{shard}', '{replica}') order by %s settings allow_nullable_key=1 |
   | ClickHouse Output Table Engine Template | Default is ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/{table}/{shard}', '{replica}') order by %s settings allow_nullable_key=1. Users can also modify according to the format. |
   | join_use_nulls                         | Can be 0 or 1, affects the behavior of join.                                                                              |
   | Hierarchical loading of schema and tables | Default is off. When enabled, schemas and tables are loaded hierarchically. Only schemas are loaded during connection, and you need to click the schema to load the tables under it. |
   | Query Timeout (seconds)                 | Default is 600. When the data volume is large, you can appropriately increase the timeout.                                |
   | Allow Write Operations                  | Indicates that this connection can be selected as an output connection in [Data Integration](pipeline.md) and [Batch Sync](batch-sync.md). You must have write permission to the database and pass verification before configuring this parameter. |
   | Support uploading files to specified path| Indicates the database name where the generated table is stored when creating a local file dataset. You must have write permission to the database and pass verification before configuring this parameter. |
   | Show only tables under specified database/schema | When this option is selected and the database field is not empty, only tables under the specified db will be displayed. |

4. After filling in the parameters, click the `Validate` button to get the validation result (this checks the connectivity between HENGSHI SENSE and the configured data connection; you cannot add the connection if validation fails).

5. After validation passes, `Allow Write Operations` and `Support uploading files to specified path` will be enabled and can be optionally turned on.

6. Click `Execute Preset Code` to pop up the preset code for this data source, then click the execute button.

7. Click the `Add` button to add the `ClickHouse` connection.

> \[!CAUTION] Please note
>
> 1. Parameters marked with \* are required; others are optional.
> 2. When connecting to a data source, you must execute the preset code. Failure to do so may result in certain functions being unavailable during data analysis. In addition, when upgrading from a version prior to 4.4 to 4.4, you need to execute the preset code for existing data connections in the system.

***

### Supported `clickhouse` Versions

`21.2` and above
