# ch2rs **Repository Path**: mirrors_ClickHouse/ch2rs ## Basic Information - **Project Name**: ch2rs - **Description**: Generate Rust structs from ClickHouse rows - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-07-30 - **Last Updated**: 2026-02-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ch2rs An auxiliary utility for generating Rust structures from ClickHouse DB schemas for the official [clickhouse-rs](https://github.com/ClickHouse/clickhouse-rs) crate. ## Usage ```sh cargo install ch2rs ``` The crate enables `rustls-tls` [client](https://github.com/ClickHouse/clickhouse-rs/blob/main/Cargo.toml) feature by default, which allows to work with HTTPS URLs. If `rustls-tls` does not work in your use case, you can install the crate with `native-tls` instead: ```sh cargo install ch2rs --features native-tls ``` ### Help ```sh $ ch2rs --help ``` ``` ch2rs 0.1.7 USAGE: ch2rs [FLAGS] [OPTIONS] FLAGS: -D Generate `Deserialize` instances -h, --help Prints help information --owned Generate only owned types -S Generate `Serialize` instances -V, --version Prints version information OPTIONS: -B ... Add `#[serde(with = "serde_bytes")]` to the provided column -d A database where the table is placed in [default: default] -I ... Ignore a specified column -O ... Override the type of the provided column -p --derive ... Add `#[derive()]` to the generated types -T ... Override the type, e.g. 'Decimal(18, 9)=fixnum::FixedPoint' -U ClickHouse server's URL [default: localhost:8123] --temporal Temporal mapping: raw|time|chrono [default: raw] -u ARGS:
The table's name ``` ### Temporal modes - **raw** (default): uses primitive Rust types: - Date → `u16`, Date32 → `i32` - DateTime → `u32`, DateTime64(_) → `i64` - Time → `i32`, Time64(_) → `i64` - **time**: uses the `time` crate types - Date/Date32: `time::Date` - DateTime/DateTime64: `time::OffsetDateTime` - Time/Time64: `time::Duration` - Requires in your project: `time` dependency and `clickhouse` feature `time` - `clickhouse = { version = "…", features = ["time"] }` - **chrono**: uses the `chrono` crate types - Date/Date32: `chrono::NaiveDate` - DateTime/DateTime64: `chrono::DateTime` - Time/Time64: `chrono::Duration` - Requires in your project: `chrono` dependency and `clickhouse` feature `chrono` - `clickhouse = { version = "…", features = ["chrono"] }` Select mode via `--temporal {raw|time|chrono}`. ## Examples See [snapshots](tests/snapshots).