> For the complete documentation index, see [llms.txt](https://integrations.drivetrain.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://integrations.drivetrain.ai/integration-guide/readme/databases-and-warehouses/integrating-with-clickhouse.md).

# Integrating with ClickHouse

Connect a ClickHouse database and sync its tables and views into Drivetrain

## Overview

Drivetrain connects to ClickHouse over its HTTPS interface. One ClickHouse connector covers one database, once you connect it, you choose which tables and views inside that database to sync. You don't create a separate connector for each table.

## Connection details

Provide these values when you add the connector:

| Field    | Description                                                        |
| -------- | ------------------------------------------------------------------ |
| Hostname | Your ClickHouse host, e.g. `abc123.us-east-1.aws.clickhouse.cloud` |
| Port     | The HTTPS interface port, `8443` on ClickHouse Cloud               |
| Username | A read-only user (see Permissions below)                           |
| Password | Password for that user                                             |
| Database | The database whose tables you want to sync, e.g. `analytics`       |

Drivetrain validates the credentials by running `SELECT 1` against the database before saving the connection.

## Selecting tables and views

Once the connection validates, Drivetrain lists every table and view in the database that your user can read. Select as many as you need, each one syncs into its own table in Drivetrain, and you can add or remove objects later without recreating the connector.

Because the database is already set on the connection, names appear unqualified (`orders`, not `analytics.orders`). There's nowhere in setup to type a table name or a SQL query, you select from the list.

### Syncing more than one database

Table listing is scoped to the database in the connection. To sync tables from a second database, add a second ClickHouse connector with that database name. The host, port, and credentials can stay the same.

## Permissions

The user needs:

* `SELECT` on each table or view you sync.
* Read access to the underlying tables of any view you sync.

**Tip:** Use a dedicated read-only user scoped to just the objects you want to share.

## Using views to shape what you share

Selecting a raw table works, Drivetrain reads its full contents. Views are optional, and they give you tighter control over what leaves your warehouse and over sync volume. A view lets you:

* Expose only the columns Drivetrain needs, instead of a whole wide table.
* Pre-aggregate or pre-filter, for example, restrict to the last 24 months.
* Encapsulate joins so Drivetrain reads one object instead of several.

Create the view in the database you connected and grant your Drivetrain user `SELECT` on it. It appears in the list alongside regular tables, and you select it the same way, no different connector, credentials, or setup steps.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://integrations.drivetrain.ai/integration-guide/readme/databases-and-warehouses/integrating-with-clickhouse.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
