https://github.com/clickhouse/ch2rs
Generate Rust structs from ClickHouse rows
https://github.com/clickhouse/ch2rs
Last synced: 12 months ago
JSON representation
Generate Rust structs from ClickHouse rows
- Host: GitHub
- URL: https://github.com/clickhouse/ch2rs
- Owner: ClickHouse
- Created: 2021-05-28T16:23:03.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-30T08:21:57.000Z (over 1 year ago)
- Last Synced: 2025-03-31T04:05:35.258Z (about 1 year ago)
- Language: Rust
- Size: 97.7 KB
- Stars: 32
- Watchers: 6
- Forks: 5
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
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]
-u
ARGS:
The table's name
```
## Examples
See [snapshots](tests/snapshots).