Connection details

ParameterValue
Hosthttps://clickhouse.us-east-2.propeldata.com
Port8443
Databasepropel
userYour Propel Application ID
passwordYour Propel Application secret

To connect a client, you must create a Propel Application and give it the DATAPOOL_QUERY scope.

ClickHouse clients and SDKs

ClickHouse HTTPS interface

The ClickHouse HTTPS interface provides a simple way to query Propel’s Serverless ClickHouse using HTTP requests. Since it uses standard HTTP, you can use it with:

  • Any programming language with HTTP support
  • Command line tools like cURL
  • API testing tools like Postman

To connect, send POST requests to this endpoint:

echo 'SELECT 1' | \
curl https://clickhouse.us-east-2.propeldata.com:8443 \
  --user "$APPLICATION_ID:$APPLICATION_SECRET" \
  --data-binary @-

Python

To get started with the ClickHouse Python client:

1

Install the package

pip install clickhouse-driver
2

Import and create a client

from clickhouse_driver import Client

client = Client(
    host='clickhouse.us-east-2.propeldata.com',
    port=8443,
    secure=True,
    user=os.environ['APPLICATION_ID'],
    password=os.environ['APPLICATION_SECRET'],
    database='default'
)
3

Execute queries

result = client.execute('SELECT 1')
for row in result:
    print(row)

Make sure to set the APPLICATION_ID and APPLICATION_SECRET environment variables before running the application.

For more detailed documentation, refer to the ClickHouse Python client documentation.

JavaScript

The official JS client. It’s written in TypeScript and provides type definitions and has zero dependencies. Two versions are available:

  • @clickhouse/client for Node.js
  • @clickhouse/client-web for browsers and Cloudflare workers

To get started with the ClickHouse JS client:

1

Install the package

2

Import and create a client

import { createClient } from '@clickhouse/client'

const client = createClient({
  host: 'https://clickhouse.us-east-2.propeldata.com',
  username: process.env.APPLICATION_ID,
  password: process.env.APPLICATION_SECRET
})

If your environment doesn’t support ESM modules, you can use CommonJS syntax:

const { createClient } = require('@clickhouse/client')

const client = createClient({
  host: 'https://clickhouse.us-east-2.propeldata.com',
  username: process.env.APPLICATION_ID,
  password: process.env.APPLICATION_SECRET
})
3

Execute queries

const result = await client.query({
  query: 'SELECT 1'
})

console.log(result.rows)

When using TypeScript, at least version 4.5+ is required.

Make sure to set the APPLICATION_ID and APPLICATION_SECRET environment variables before running the application.

ClickHouse JS supports various query formats, data streaming, and advanced features like query cancellation and custom settings. For more detailed documentation, refer to the ClickHouse JS client documentation.

Go

To get started with the ClickHouse Go client:

1

Install the ClickHouse Go driver

go get -u github.com/ClickHouse/clickhouse-go/v2
2

Import and create a connection

package main

import (
    "context"
    "fmt"
    "log"
    "github.com/ClickHouse/clickhouse-go/v2"
)

func main() {
    conn, err := clickhouse.Open(&clickhouse.Options{
        Addr: []string{"clickhouse.us-east-2.propeldata.com:8443"},
        Auth: clickhouse.Auth{
            Database: "default",
            Username: os.Getenv("APPLICATION_ID"),
            Password: os.Getenv("APPLICATION_SECRET"),
        },
        TLS: &tls.Config{
            InsecureSkipVerify: true,
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    defer conn.Close()

    // Check if the connection is alive
    if err := conn.Ping(context.Background()); err != nil {
        log.Fatal(err)
    }
}
3

Execute queries

ctx := context.Background()
rows, err := conn.Query(ctx, "SELECT 1")
if err != nil {
    log.Fatal(err)
}
defer rows.Close()

for rows.Next() {
    var (
        col1 int
        // Add more variables for each column in your table
    )
    if err := rows.Scan(&col1); err != nil {
        log.Fatal(err)
    }
    fmt.Printf("col1: %s: %d\n", col1)
}

if err := rows.Err(); err != nil {
    log.Fatal(err)
}

Make sure to set the APPLICATION_ID and APPLICATION_SECRET environment variables before running the application.

For more detailed documentation, refer to the ClickHouse Go driver documentation.

Java

To get started with the ClickHouse Java client:

1

Add the dependency

<dependency>
    <groupId>com.clickhouse</groupId>
    <artifactId>clickhouse-client</artifactId>
    <version>0.4.6</version>
</dependency>
2

Connect to the database

import com.clickhouse.client.*;
import com.clickhouse.data.ClickHouseFormat;

public class ClickHouseExample {
    public static void main(String[] args) {
        String url = "https://clickhouse.us-east-2.propeldata.com:8443";
        String database = "propel";
        String user = System.getenv("APPLICATION_ID");
        String password = System.getenv("APPLICATION_SECRET");

        try (ClickHouseClient client = ClickHouseClient.newInstance(url);
             ClickHouseNode server = ClickHouseNode.builder()
                 .host(url)
                 .database(database)
                 .credentials(ClickHouseCredentials.fromUserAndPassword(user, password))
                 .build()) {

            System.out.println("Connected successfully");
        } catch (Exception e) {
            System.err.println("Connection failed: " + e.getMessage());
        }
    }
}
3

Execute queries

String query = "SELECT 1";
try (ClickHouseClient client = ClickHouseClient.newInstance(url);
     ClickHouseResponse response = client.read(server)
         .format(ClickHouseFormat.RowBinaryWithNamesAndTypes)
         .query(query)
         .execute()) {

    for (ClickHouseRecord record : response.records()) {
        String col1 = record.getValue("column1").asString();
        int col2 = record.getValue("column2").asInteger();
        // Add more variables for each column in your table
        System.out.printf("col1: %s, col2: %d%n", col1, col2);
    }
} catch (Exception e) {
    System.err.println("Query execution failed: " + e.getMessage());
}

Make sure to set the APPLICATION_ID and APPLICATION_SECRET environment variables before running the application.

For more detailed documentation, refer to the ClickHouse Java client documentation.

Rust

To get started with the ClickHouse Rust client:

1

Add the dependency

[dependencies]
clickhouse = "0.13.1"
2

Create a client instance

use clickhouse::Client;

let client = Client::default()
    // should include both protocol and port
    .with_url("https://clickhouse.us-east-2.propeldata.com:8443")
    .with_user(os.getenv("APPLICATION_ID"))
    .with_password(os.getenv("APPLICATION_SECRET"))
    .with_database("propel");
3

Execute queries

use serde::Deserialize;
use clickhouse::Row;
use clickhouse::sql::Identifier;

#[derive(Row, Deserialize)]
struct MyRow<'a> {
    no: u32,
    name: &'a str,
}

let table_name = "some";
let mut cursor = client
    .query("SELECT ?fields FROM ? WHERE no BETWEEN ? AND ?")
    .bind(Identifier(table_name))
    .bind(500)
    .bind(504)
    .fetch::<MyRow<'_>>()?;

while let Some(row) = cursor.next().await? { .. }

For more details about query execution:

  • The ?fields placeholder is replaced with the fields specified in the Row struct (no, name in the example above).
  • The ? placeholders are replaced with values from subsequent bind() calls in order.
  • Convenience methods fetch_one::<Row>() and fetch_all::<Row>() are available to get a single row or all rows.
  • Use sql::Identifier to safely bind table names.

For more detailed documentation, refer to the ClickHouse Rust client documentation.

PostgreSQL clients and SDKs

psql (PostgreSQL CLI)

To get started with the PostgreSQL CLI, psql, follow the steps below.

PGPASSWORD=$APPLICATION_SECRET \
psql -h postgresql.us-east-2.propeldata.com \
  -d propel \
  -U $APPLICATION_ID

After a successful connection, you can make the query below.

propel=> SELECT 1;

Postgres.js

To get started with the Postgres.js client:

1

Install the package

npm i postgres
2

Create connection file

// db.js
import postgres from 'postgres'

const sql = postgres({
  host: 'postgresql.us-east-2.propeldata.com',
  port: 5432,
  database: 'propel',
  username: process.env.APPLICATION_ID,
  password: process.env.APPLICATION_SECRET
})

export default sql
3

Set environment variables

Create APPLICATION_ID and APPLICATION_SECRET environment variables with your actual credentials.

4

Execute queries

import sql from './db.js'

async function select() {
  try {
    const result = await sql`
      SELECT 1
    `
    console.log(result)
    return result
  } catch (error) {
    console.error('Error executing query:', error)
  } finally {
    sql.end()
  }
}