ClickHouse

This page describes how to create and maintain connections to your ClickHouse database.

Before you can write your data to ClickHouse, you should first establish a connection to your ClickHouse database.

Create a ClickHouse connection

Simple example

CREATE CLICKHOUSE CONNECTION my_clickhouse_connection
    CONNECTION_STRING = 'http://upsolver_demo:8123/sales_orders'
    USER_NAME = 'dbuser1'
    PASSWORD = 'mypassword';

Alter a ClickHouse connection

Certain connection options are considered mutable, meaning that in some cases, you can run a SQL command to alter an existing ClickHouse connection rather than creating a new one.

For example, take the ClickHouse connection we created previously:

CREATE CLICKHOUSE CONNECTION my_clickhouse_connection
    CONNECTION_STRING = 'http://upsolver_demo:8123/sales_orders'
    USER_NAME = 'dbuser1'
    PASSWORD = 'mypassword';

To change the database you are connecting to but keep everything else the same without having to create an entirely new connection, you can run the following command:

ALTER CLICKHOUSE CONNECTION my_clickhouse_connection
    SET CONNECTION_STRING = 'http://upsolver_demo:8123/sales_orders_usa';

Drop a ClickHouse connection

If you no longer need a connection, you can easily drop it with the following SQL command:

DROP CONNECTION my_clickhouse_connection; 

However, note that if there are existing tables or jobs that are dependent upon the connection in question, the connection cannot be deleted.


Learn More

Last updated