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:
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.
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.
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.
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.
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.