To connect your deployment with BI tools, refer to the dedicated documentation.
How to Connect Applications to Your Deployment
This page explains how to connect yourself or your applications to your Data Warehouse for ClickHouse® deployment using the Scaleway console.
To connect your deployment with BI tools, refer to the dedicated documentation.
Before you startLink to this anchor
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- Signed up to the private beta and received a confirmation email.
- Created a Data Warehouse deployment
-
Click ClickHouse® under Data & Analytics on the side menu. The Data Warehouse deployment page displays.
-
Click the name of the Data Warehouse deployment you want to connect to. The overview tab of the deployment displays.
-
Click the Actions button in the top-right corner of the page. A drop-down menu displays.
-
Select Connect using frameworks. The connection wizard displays.
Note -
Select your preferred framework:
Protocols
Select the appropriate protocol, then run the displayed command in a terminal. Remember to replace the placeholders with the appropriate values, and to specify the correct path to the certificate file.
clickhouse client \--host <YOUR_DEPLOYMENT_ID>.dtwh.<REGION>.scw.cloud \--port 9440 \--secure \--user scwadmin \--password '<PASSWORD>'mysql -h <YOUR_DEPLOYMENT_ID>.dtwh.<REGION>.scw.cloud \-P 9004 \-u scwadmin \--password='<PASSWORD>' -e "SELECT 1;"NoteMySQL connection is exposed publicly. Use ClickHouse® CLI for a secure connection.
echo 'SELECT 1' | curl 'https://scwadmin:<PASSWORD>@<YOUR_DEPLOYMENT_ID>.dtwh.<REGION>.scw.cloud:443' -d @-Notecurl
only works with SQL queries, and does not allow direct connection to your Data Warehouse for ClickHouse® deployment.
Languages
Select the desired language, then run the code displayed to create a file that connects to your deployment, and run queries programmatically. Remember to replace the placeholders with the appropriate values, and to specify the correct path to the certificate file.
pip install clickhouse-connectcat <<EOF >clickhouse.pyimport clickhouse_connectclient = clickhouse_connect.get_client(host="<YOUR_DEPLOYMENT_ID>.dtwh.<REGION>.scw.cloud",port=443,username="scwadmin",password="<PASSWORD>",)query_result = client.query("SELECT 1")print(query_result.result_set)EOFpython clickhouse.pymkdir ClickHouse-gocd ClickHouse-gogo mod init ClickHouse-gocat <<EOF >main.gopackage mainimport ("context""fmt""log""github.com/ClickHouse/clickhouse-go/v2")func main() {conn, err := clickhouse.Open(&clickhouse.Options{Addr: []string{"f133556f-8578-486f-be7f-49f7da08b728.dtwh.fr-par.scw.cloud:9440"},Auth: clickhouse.Auth{Database: "default",Username: "scwadmin",Password: "PASSWORD",},})if err != nil {log.Fatal(err)}defer conn.Close()ctx := context.Background()var result stringif err := conn.QueryRow(ctx, "SELECT 1").Scan(&result); err != nil {log.Fatal(err)}fmt.Println(result)}EOFgo run .npm i @clickhouse/clientcat <<EOF >clickhouse.jsimport { createClient } from '@clickhouse/client'void (async () => {const client = createClient({url: 'https://f133556f-8578-486f-be7f-49f7da08b728.dtwh.fr-par.scw.cloud:443',username: 'scwadmin',password: 'PASSWORD'})const rows = await client.query({query: 'SELECT 1',format: 'JSONEachRow',})console.info(await rows.json())await client.close()})()EOFnode clickhouse.jscat <<EOF >pom.xml<?xml version="1.0" encoding="UTF-8"?><projectxsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><modelVersion>4.0.0</modelVersion><groupId>clickhouse-java</groupId><artifactId>clickhouse-java</artifactId><version>1.0.0</version><packaging>jar</packaging><dependencies><dependency><groupId>com.clickhouse</groupId><artifactId>clickhouse-jdbc</artifactId><version>0.7.2</version></dependency></dependencies></project>EOFmkdir -p src/main/javacat <<EOF >src/main/java/Main.javaimport java.sql.*;import java.lang.ClassNotFoundException;public class Main {public static void main(String[] args) throws SQLException, ClassNotFoundException {Class.forName("com.clickhouse.jdbc.ClickHouseDriver");String url = "jdbc:ch://scwadmin:PASSWORD@f133556f-8578-486f-be7f-49f7da08b728.dtwh.fr-par.scw.cloud:443/default?ssl=true";try (Connection con = DriverManager.getConnection(url); Statement stmt = con.createStatement()) {ResultSet result_set = stmt.executeQuery("SELECT 1 AS one");while (result_set.next()) {System.out.println(result_set.getInt("one"));}}}}EOFmvn clean compilemvn exec:java -Dexec.mainClass=Main
You are now connected to your Data Warehouse for ClickHouse® deployment using the administrator account.