# ClickHouse

Go to the workspace settings, then to the Source tab, and click "Add New Source".

* **Step 1:** Select ClickHouse from the list of available sources<br>
* **Step 2:** Create a DinMo user on your DataWarehouse and the DinMo technical datasets.\
  \
  DinMo needs to read all the tables that you want to use to build models and segments. It also needs to write access to a database that will be used to store technical data (segment queries, segment stats, activation snapshots).<br>

  We recommend you create a specific user and role for DinMo and grant them the needed permissions.

  You can do so by running the following SQL snippet.

```sql
-- Create the technical database that DinMo will use to store its internal data
CREATE DATABASE IF NOT EXISTS dinmo_technical_data;

-- Give the DinMo user the ability to sign in with a password
CREATE USER IF NOT EXISTS DINMO_USER IDENTIFIED WITH bcrypt_password BY '<strong, unique password>';
CREATE ROLE IF NOT EXISTS DINMO_ROLE;
GRANT DINMO_ROLE TO DINMO_USER;

-- Let the DinMo Role read and query the database that contains the data that you want to use in the DinMo Platform
-- You can have fine-grained access control by granting permissions only on specific tables or views instead of the whole database
-- Replace <your database> with the name of the database where you store the tables and views that will be used in the DinMo Platform
GRANT SELECT ON <your database>.* TO DINMO_ROLE;

-- Grant the DinMo Role full access to the technical database
GRANT SELECT ON dinmo_technical_data.* TO DINMO_ROLE;
GRANT CREATE, DROP TABLE ON dinmo_technical_data.* TO DINMO_ROLE;
GRANT CREATE, DROP VIEW ON dinmo_technical_data.* TO DINMO_ROLE;
GRANT INSERT ON dinmo_technical_data.* TO DINMO_ROLE;
```

Please edit the `<value>` fields in the script to define your own credentials and parameters.<br>

* **Step 3:** Fill in the required information<br>
  * Url: The url or IP address.<br>
  * Database: The name of the database.<br>
  * Port: The port number. The default is 8443, but yours may be different.<br>
  * User and password: The credentials you created in the script above.<br>
* **Step 4:** Hit "Save & Test". This will launch a test ensuring that the connection is working. If so, congratulations, your source setup is finished!

***

If you encounter an error or question not listed below and need assistance, don't hesitate to reach out to your account manager or <support@dinmo.com>. We're here to help!


---

# Agent Instructions: 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:

```
GET https://docs.dinmo.io/integrations/data-sources/clickhouse.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
