An auxiliary utility for generating Rust structures from ClickHouse DB schemas for the official clickhouse-rs crate.
cargo install ch2rs
The crate enables rustls-tls client 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:
cargo install ch2rs --features native-tls
$ ch2rs --help
ch2rs 0.1.7
USAGE:
ch2rs [FLAGS] [OPTIONS] <table>
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 <bytes>... Add `#[serde(with = "serde_bytes")]` to the provided column
-d <database> A database where the table is placed in [default: default]
-I <ignore>... Ignore a specified column
-O <overrides>... Override the type of the provided column
-p <password>
--derive <trait>... Add `#[derive(<trait>)]` to the generated types
-T <types>... Override the type, e.g. 'Decimal(18, 9)=fixnum::FixedPoint<i64, typenum::U9>'
-U <url> ClickHouse server's URL [default: localhost:8123]
--temporal <mode> Temporal mapping: raw|time|chrono [default: raw]
-u <user>
ARGS:
<table> The table's name
raw (default): uses primitive Rust types:
u16, Date32 → i32u32, DateTime64(_) → i64i32, Time64(_) → i64time: uses the time crate types
time::Datetime::OffsetDateTimetime::Durationtime dependency and clickhouse feature time
clickhouse = { version = "…", features = ["time"] }chrono: uses the chrono crate types
chrono::NaiveDatechrono::DateTime<chrono::Utc>chrono::Durationchrono dependency and clickhouse feature chrono
clickhouse = { version = "…", features = ["chrono"] }Select mode via --temporal {raw|time|chrono}.
See snapshots.
Rust
100.0%
An auxiliary utility for generating Rust structures from ClickHouse DB schemas for the official clickhouse-rs crate.
cargo install ch2rs
The crate enables rustls-tls client 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:
cargo install ch2rs --features native-tls
$ ch2rs --help
ch2rs 0.1.7
USAGE:
ch2rs [FLAGS] [OPTIONS] <table>
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 <bytes>... Add `#[serde(with = "serde_bytes")]` to the provided column
-d <database> A database where the table is placed in [default: default]
-I <ignore>... Ignore a specified column
-O <overrides>... Override the type of the provided column
-p <password>
--derive <trait>... Add `#[derive(<trait>)]` to the generated types
-T <types>... Override the type, e.g. 'Decimal(18, 9)=fixnum::FixedPoint<i64, typenum::U9>'
-U <url> ClickHouse server's URL [default: localhost:8123]
--temporal <mode> Temporal mapping: raw|time|chrono [default: raw]
-u <user>
ARGS:
<table> The table's name
raw (default): uses primitive Rust types:
u16, Date32 → i32u32, DateTime64(_) → i64i32, Time64(_) → i64time: uses the time crate types
time::Datetime::OffsetDateTimetime::Durationtime dependency and clickhouse feature time
clickhouse = { version = "…", features = ["time"] }chrono: uses the chrono crate types
chrono::NaiveDatechrono::DateTime<chrono::Utc>chrono::Durationchrono dependency and clickhouse feature chrono
clickhouse = { version = "…", features = ["chrono"] }Select mode via --temporal {raw|time|chrono}.
See snapshots.
Rust
100.0%