clickhouse-rs 0.1.0

clickhouse-rs is a library for accessing a Yandex ClickHouse database over native interface from the tokio.
Documentation

ClickHouse Rust client

clickhouse-rs is a library for accessing a Yandex ClickHouse database over native interface from the tokio.

Supported data types

  • Date
  • DateTime
  • Float32, Float64
  • String
  • UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64

Example

extern crate clickhouse_rs;
extern crate tokio;

use clickhouse_rs::*;
use tokio::prelude::*;

fn main() {
    let ddl =
        "CREATE TABLE IF NOT EXISTS person(
            person_id UInt32,
            name      String
         ) ENGINE=TinyLog";

    let block = Block::new()
        .add_column("person_id", vec![1u32,     2,        3       ])
        .add_column("name",      vec!["Steven", "Amelia", "Oliver"]);

    let options = Options::new("127.0.0.1:9000".parse().unwrap());
    let done = Client::connect(options)
        .and_then(|c| c.ping())
        .and_then(move |c| c.execute(ddl))
        .and_then(move |c| c.insert("person", block))
        .and_then(move |c| c.query_all("SELECT * FROM person"))
        .and_then(|(block, _)| {
            for row in 0 .. block.row_count() {
                let id: u32    = block.get(row, "person_id")?;
                let name: &str = block.get(row, "name")?;
                println!("Found person {}: {}", id, name);
            }
            Ok(())
        })
        .map_err(|err| println!("database error: {}", err));

    tokio::run(done)
}