How to connect 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 start
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.
-
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;"
echo 'SELECT 1' | curl 'https://scwadmin:<PASSWORD>@<YOUR_DEPLOYMENT_ID>.dtwh.<REGION>.scw.cloud:443' -d @-
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-connect cat <<EOF >clickhouse.py import clickhouse_connect client = 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) EOF python clickhouse.py
mkdir ClickHouse-go cd ClickHouse-go go mod init ClickHouse-go cat <<EOF >main.go package main import ( "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 string if err := conn.QueryRow(ctx, "SELECT 1").Scan(&result); err != nil { log.Fatal(err) } fmt.Println(result) } EOF go run .
npm i @clickhouse/client cat <<EOF >clickhouse.js import { 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() })() EOF node clickhouse.js
cat <<EOF >pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xsi: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> EOF mkdir -p src/main/java cat <<EOF >src/main/java/Main.java import 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")); } } } } EOF mvn clean compile mvn exec:java -Dexec.mainClass=Main
You are now connected to your Data Warehouse for ClickHouse® deployment using the administrator account.