#clickhouse #sql-database #sql #tokio

klickhouse

Klickhouse is a pure Rust SDK for working with Clickhouse with the native protocol in async environments with minimal boilerplate and maximal performance

39 releases (11 breaking)

0.12.0 Apr 1, 2024
0.11.2 Feb 28, 2024
0.11.0 Jan 15, 2024
0.10.2 Oct 28, 2023
0.2.1 May 31, 2021

#447 in Database interfaces

Download history 4/week @ 2024-01-02 173/week @ 2024-01-09 196/week @ 2024-01-16 169/week @ 2024-01-23 229/week @ 2024-01-30 24/week @ 2024-02-06 43/week @ 2024-02-13 258/week @ 2024-02-20 606/week @ 2024-02-27 453/week @ 2024-03-05 199/week @ 2024-03-12 517/week @ 2024-03-19 426/week @ 2024-03-26 603/week @ 2024-04-02 409/week @ 2024-04-09 421/week @ 2024-04-16

1,952 downloads per month

MIT/Apache

325KB
8K SLoC

Klickhouse

Klickhouse is a pure Rust SDK for working with Clickhouse with the native protocol in async environments with minimal boilerplate and maximal performance.

Example Usage

See example usage.

Unsupported Features

  • Clickhouse Enum8 and Enum16 types -- use LowCardinality instead.

Running the tests

A Clickhouse server is required to run the integration tests. One can be started easily in a Docker container:

$ docker run  --rm --name clickhouse -p 19000:9000 --ulimit nofile=262144:262144 clickhouse
$ export KLICKHOUSE_TEST_ADDR=127.0.0.1:19000
$ # export KLICKHOUSE_TEST_USER=default
$ # export KLICKHOUSE_TEST_PASSWORD=default
$ # export KLICKHOUSE_TEST_DATABASE=default
$ cargo nextest run

(running the tests simultaneously with cargo test is currently not suported, due to loggers initializations.)

Feature flags

  • derive: Enable [klickhouse_derive], providing a derive macro for the [Row] trait. Default.
  • compression: lz4 compression for client/server communication. Default.
  • serde: Derivation of serde::Serialize and serde::Deserialize on various objects, and JSON support. Default.
  • tls: TLS support via tokio-rustls.
  • refinery: Migrations via refinery.
  • geo-types: Conversion of geo types to/from the geo-types crate.
  • bb8: Enables a ConnectionManager managed by bb8

Credit

klickhouse_derive was made by copy/paste/simplify of serde_derive to get maximal functionality and performance at lowest time-cost. In a prototype, serde was directly used, but this was abandoned due to lock-in of serde's data model.

Dependencies

~9–23MB
~314K SLoC