> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bondata.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# ClickHouse

> Connect BonData to ClickHouse to sync your analytical database tables

ClickHouse is a fast, open-source column-oriented OLAP database designed for real-time analytical queries over large datasets. With BonData, you can connect directly to your ClickHouse database to read, enrich, and act on your data within Agent workflows.

## Database Connection

BonData connects to ClickHouse over a secure interface. Both **ClickHouse Cloud** and **self-hosted** deployments are supported.

### Step 1: Gather Your Connection Details

<Tabs>
  <Tab title="ClickHouse Cloud">
    1. Log in to the [ClickHouse Cloud console](https://clickhouse.cloud/)
    2. Select your service and open **Connect**
    3. Copy the **host** (e.g., `abc123.us-east-1.aws.clickhouse.cloud`)
    4. Use port **8443** for the HTTPS interface (or **9440** for the native TLS interface)
  </Tab>

  <Tab title="Self-Hosted">
    1. Identify the hostname or IP address of your ClickHouse server
    2. Ensure the HTTPS interface (default port **8443**) or the native TLS interface (default port **9440**) is enabled
    3. Confirm your firewall allows connections from BonData's IP addresses
  </Tab>
</Tabs>

### Step 2: Create a Read-Only User (Recommended)

For security, create a dedicated read-only user for BonData:

```sql theme={null}
-- Create a user for BonData
CREATE USER bondata_user IDENTIFIED BY 'your_secure_password';

-- Grant read access to your database
GRANT SELECT ON your_database.* TO bondata_user;
```

### Step 3: Gather Connection Details

Collect the following information:

* **Host**: Your ClickHouse server hostname
* **Port**: `8443` (HTTPS) or `9440` (native TLS)
* **Database**: The name of the database to connect to
* **User**: The username created above
* **Password**: The password for the user

### Step 4: Connect in BonData

Enter your connection details in BonData to establish the connection.

## Required Fields

| Field    | Description                                                              |
| -------- | ------------------------------------------------------------------------ |
| Host     | Database server hostname (e.g., `abc123.us-east-1.aws.clickhouse.cloud`) |
| Port     | HTTPS interface `8443` or native TLS interface `9440`                    |
| Database | Name of the database to connect to                                       |
| User     | Database username                                                        |
| Password | Database password                                                        |

<Note>
  BonData connects to ClickHouse over TLS. ClickHouse Cloud services require a secure connection; for self-hosted deployments, enable the HTTPS or native TLS port before connecting.
</Note>

## Available Data

Once connected, BonData can sync:

* **Tables** - All tables the user has SELECT access to
* **Views** - Standard views accessible to the user
* **Materialized Views** - Materialized views accessible to the user
* **Custom Queries** - Run custom SQL queries to extract specific data
