suharev7/clickhouse-rs
소개
Asynchronous ClickHouse client library for Rust programming language.
프로그래밍 언어 및 런타임What you can do
- tokio_io (enabled by default) — I/O based on Tokio.
- async_std — I/O based on async-std (doesn't work together with tokio_io).
- tls — TLS support (allowed only with tokio_io).
측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- +1
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalAsync ClickHouse Client
Asynchronous Yandex ClickHouse client library for rust programming language.
Installation
Library hosted on crates.io.
[dependencies]
clickhouse-rs = "*"
Supported data types
- Date
- DateTime
- Decimal(P, S)
- Float32, Float64
- String, FixedString(N)
- UInt8, UInt16, UInt32, UInt64, UInt128, Int8, Int16, Int32, Int64, Int128
- Nullable(T)
- Array(UInt/Int/Float/String/Date/DateTime)
- SimpleAggregateFunction(F, T)
- IPv4/IPv6
- UUID
- Bool
DNS
schema://user:password@host[:port]/database?param1=value1&...¶mN=valueN
parameters:
compression- Whether or not use compression (defaults tonone). Possible choices:nonelz4
connection_timeout- Timeout for connection (defaults to500 ms)query_timeout- Timeout for queries (defaults to180 sec).insert_timeout- Timeout for inserts (defaults to180 sec).execute_timeout- Timeout for execute (defaults to180 sec).keepalive- TCP keep alive timeout in milliseconds.nodelay- Whether to enableTCP_NODELAY(defaults totrue).pool_min- Lower bound of opened connections forPool(defaults to10).pool_max- Upper bound of opened connections forPool(defaults to20).ping_before_query- Ping server every time before execute any query. (defaults totrue).send_retries- Count of retry to send request to server. (defaults to3).retry_timeout- Amount of time to wait before next retry. (defaults to5 sec).ping_timeout- Timeout for ping (defaults to500 ms).alt_hosts- Comma separated list of single address host for load-balancing.
example:
tcp://user:password@host:9000/clicks?compression=lz4&ping_timeout=42ms
Optional features
clickhouse-rs puts some functionality behind optional features to optimize compile time
for the most common use cases. The following features are available.
tokio_io(enabled by default) — I/O based on Tokio.async_std— I/O based on async-std (doesn't work together withtokio_io).tls— TLS support (allowed only withtokio_io).
Example
use clickhouse_rs::{Block, Pool};
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
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(())
}
관련 프로젝트 살펴보기
불러오는 중…