### Example ClickHouse Connection URL with Parameters Source: https://github.com/suharev7/clickhouse-rs/blob/async-await/README.md This example demonstrates a practical ClickHouse connection URL, showcasing how to specify the `tcp` schema, user credentials, host, port, database, and include specific parameters like `compression` (set to `lz4`) and `ping_timeout` (set to `42ms`). ```url tcp://user:password@host:9000/clicks?compression=lz4&ping_timeout=42ms ``` -------------------------------- ### Complete ClickHouse-rs Usage Example in Rust Source: https://github.com/suharev7/clickhouse-rs/blob/async-await/README.md This comprehensive Rust example illustrates the full lifecycle of interacting with a ClickHouse database using `clickhouse-rs`. It demonstrates creating a table with DDL, inserting structured data using a `Block`, executing both DDL and DML operations, and finally querying and iterating over the results asynchronously with `tokio`. ```rust use clickhouse_rs::{Block, Pool}; use std::error::Error; #[tokio::main] async fn main() -> Result<(), Box> { let ddl = r" CREATE TABLE IF NOT EXISTS payment ( customer_id UInt32, amount UInt32, account_name Nullable(FixedString(3)) ) Engine=Memory"; let block = Block::new() .column("customer_id", vec![1_u32, 3, 5, 7, 9]) .column("amount", vec![2_u32, 4, 6, 8, 10]) .column("account_name", vec![Some("foo"), None, None, None, Some("bar")]); let pool = Pool::new(database_url); let mut client = pool.get_handle().await?; client.execute(ddl).await?; client.insert("payment", block).await?; let block = client.query("SELECT * FROM payment").fetch_all().await?; for row in block.rows() { let id: u32 = row.get("customer_id")?; let amount: u32 = row.get("amount")?; let name: Option<&str> = row.get("account_name")?; println!("Found payment {}: {} {:?}", id, amount, name); } Ok(()) } ``` -------------------------------- ### ClickHouse Connection DNS Parameters Source: https://github.com/suharev7/clickhouse-rs/blob/async-await/README.md This section outlines the various parameters available for configuring a ClickHouse connection URL. It details options for compression, connection and query timeouts, TCP settings, connection pooling, retry mechanisms, and load-balancing, providing granular control over client behavior. ```APIDOC schema://user:password@host[:port]/database?param1=value1&...¶mN=valueN parameters: - `compression`: Whether or not use compression (defaults to `none`). Possible choices: `none`, `lz4` - `connection_timeout`: Timeout for connection (defaults to `500 ms`) - `query_timeout`: Timeout for queries (defaults to `180 sec`). - `insert_timeout`: Timeout for inserts (defaults to `180 sec`). - `execute_timeout`: Timeout for execute (defaults to `180 sec`). - `keepalive`: TCP keep alive timeout in milliseconds. - `nodelay`: Whether to enable `TCP_NODELAY` (defaults to `true`). - `pool_min`: Lower bound of opened connections for `Pool` (defaults to `10`). - `pool_max`: Upper bound of opened connections for `Pool` (defaults to `20`). - `ping_before_query`: Ping server every time before execute any query. (defaults to `true`). - `send_retries`: Count of retry to send request to server. (defaults to `3`). - `retry_timeout`: Amount of time to wait before next retry. (defaults to `5 sec`). - `ping_timeout`: Timeout for ping (defaults to `500 ms`). - `alt_hosts`: Comma separated list of single address host for load-balancing. ``` -------------------------------- ### Add clickhouse-rs Dependency to Cargo.toml Source: https://github.com/suharev7/clickhouse-rs/blob/async-await/README.md This TOML snippet demonstrates how to include the `clickhouse-rs` crate as a dependency in your Rust project's `Cargo.toml` file. It specifies the crate name and uses a wildcard for the version, indicating compatibility with any available version. ```toml [dependencies] clickhouse-rs = "*" ``` -------------------------------- ### CMake Configuration for cityhash-lib Static Library Source: https://github.com/suharev7/clickhouse-rs/blob/async-await/clickhouse-rs-cityhash-sys/src/cc/CMakeLists.txt This snippet demonstrates how to define a static library named `cityhash-lib` from `city.cc` and set its `POSITION_INDEPENDENT_CODE` property to `ON` for better compatibility and security in shared environments. ```CMake ADD_LIBRARY (cityhash-lib STATIC city.cc ) set_property(TARGET cityhash-lib PROPERTY POSITION_INDEPENDENT_CODE ON) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.