> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8a08bda2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Efficiently query very large datasets, analyzing and modeling in the comfort of known notebook environment.

# Connect ClickHouse to Deepnote

export const CommunityMaintainedBadge = () => {
  return <div className="CommunityMaintainedBadge">
            <div className="CommunityMaintainedIcon">
            <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 256 256">
                <path d="M244.8,150.4a8,8,0,0,1-11.2-1.6A51.6,51.6,0,0,0,192,128a8,8,0,0,1-7.37-4.89,8,8,0,0,1,0-6.22A8,8,0,0,1,192,112a24,24,0,1,0-23.24-30,8,8,0,1,1-15.5-4A40,40,0,1,1,219,117.51a67.94,67.94,0,0,1,27.43,21.68A8,8,0,0,1,244.8,150.4ZM190.92,212a8,8,0,1,1-13.84,8,57,57,0,0,0-98.16,0,8,8,0,1,1-13.84-8,72.06,72.06,0,0,1,33.74-29.92,48,48,0,1,1,58.36,0A72.06,72.06,0,0,1,190.92,212ZM128,176a32,32,0,1,0-32-32A32,32,0,0,0,128,176ZM72,120a8,8,0,0,0-8-8A24,24,0,1,1,87.24,82a8,8,0,1,0,15.5-4A40,40,0,1,0,37,117.51,67.94,67.94,0,0,0,9.6,139.19a8,8,0,1,0,12.8,9.61A51.6,51.6,0,0,1,64,128,8,8,0,0,0,72,120Z"></path>
            </svg>
        </div>
            Community Maintained
        </div>;
};

export const Image = ({img, alt, size}) => {
  return <Frame>
      <img src={img} alt={alt} />
    </Frame>;
};

<a href="https://www.deepnote.com/" target="_blank">Deepnote</a> is a collaborative data notebook built for teams to discover and share insights. In addition to being Jupyter-compatible, it works in the cloud and provides you with one central place to collaborate and work on data science projects efficiently.

This guide assumes you already have a Deepnote account and that you have a running ClickHouse instance.

<h2 id="interactive-example">
  Interactive example
</h2>

If you would like to explore an interactive example of querying ClickHouse from Deepnote data notebooks, click the button below to  launch a template project connected to the [ClickHouse playground](/get-started/sample-datasets/playground).

[<img src="https://deepnote.com/buttons/launch-in-deepnote.svg" alt="Launch in Deepnote" width="32" />](https://deepnote.com/launch?template=ClickHouse%20and%20Deepnote)

<h2 id="connect-to-clickhouse">
  Connect to ClickHouse
</h2>

1. Within Deepnote, select the "Integrations" overview and click on the ClickHouse tile.

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-mintlify-8a08bda2/4vIMKkFnnYA91FZ1/images/integrations/data-visualization/deepnote_01.png?fit=max&auto=format&n=4vIMKkFnnYA91FZ1&q=85&s=d59135853eb80a1b8f0fc4e82661a9a8" alt="ClickHouse integration tile" border width="3024" height="1368" data-path="images/integrations/data-visualization/deepnote_01.png" />

2. Provide the connection details for your ClickHouse instance:

To connect to ClickHouse with HTTP(S) you need this information:

| Parameter(s)              | Description                                                                                                    |
| ------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `HOST` and `PORT`         | Typically, the port is 8443 when using TLS or 8123 when not using TLS.                                         |
| `DATABASE NAME`           | Out of the box, there is a database named `default`, use the name of the database that you want to connect to. |
| `USERNAME` and `PASSWORD` | Out of the box, the username is `default`. Use the username appropriate for your use case.                     |

The details for your ClickHouse Cloud service are available in the ClickHouse Cloud console.
Select a service and click **Connect**:

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-8a08bda2/wqlFf5fgND6FRlHN/images/_snippets/cloud-connect-button.png?fit=max&auto=format&n=wqlFf5fgND6FRlHN&q=85&s=ae1aa98f2d03607ef24cd1e8f582d1c9" size="md" alt="ClickHouse Cloud service connect button" border width="998" height="932" data-path="images/_snippets/cloud-connect-button.png" />

Choose **HTTPS**. Connection details are displayed in an example `curl` command.

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-8a08bda2/wqlFf5fgND6FRlHN/images/_snippets/connection-details-https.png?fit=max&auto=format&n=wqlFf5fgND6FRlHN&q=85&s=f2fd1bd58f4e9e55c8ed987fa6d29f13" size="md" alt="ClickHouse Cloud HTTPS connection details" border width="1320" height="1184" data-path="images/_snippets/connection-details-https.png" />

If you're using self-managed ClickHouse, the connection details are set by your ClickHouse administrator.

<Image size="md" img="https://mintcdn.com/private-7c7dfe99-mintlify-8a08bda2/4vIMKkFnnYA91FZ1/images/integrations/data-visualization/deepnote_02.png?fit=max&auto=format&n=4vIMKkFnnYA91FZ1&q=85&s=7096e681e8c449907f3e2e21c59202a5" alt="ClickHouse details dialog" border width="1827" height="1061" data-path="images/integrations/data-visualization/deepnote_02.png" />

***NOTE:*** If your connection to ClickHouse is protected with an IP Access List, you might need to allow Deepnote's IP addresses. Read more about it in [Deepnote's docs](https://docs.deepnote.com/integrations/authorize-connections-from-deepnote-ip-addresses).

3. Congratulations! You have now integrated ClickHouse into Deepnote.

<h2 id="using-clickhouse-integration">
  Using ClickHouse integration.
</h2>

1. Start by connecting to the ClickHouse integration on the right of your notebook.

   <Image size="lg" img="https://mintcdn.com/private-7c7dfe99-mintlify-8a08bda2/4vIMKkFnnYA91FZ1/images/integrations/data-visualization/deepnote_03.png?fit=max&auto=format&n=4vIMKkFnnYA91FZ1&q=85&s=dc571ff81e83956da157b580267e550d" alt="ClickHouse details dialog" border width="3008" height="1086" data-path="images/integrations/data-visualization/deepnote_03.png" />

2. Now create a new ClickHouse query block and query your database. The query results will be saved as a DataFrame and stored in the variable specified in the SQL block.

3. You can also convert any existing [SQL block](https://docs.deepnote.com/features/sql-cells) to a ClickHouse block.
