[−][src]Crate klickenhaus
Simple Yandex ClickHouse client
How to use:
use klickenhaus::ClickhouseClient; let ch = ClickhouseClient::new("http://localhost:8123"); assert!(ch.ping()); ch.query("DROP TABLE IF EXISTS test_table").expect("query failed"); ch.query("CREATE TABLE IF NOT EXISTS test_table (a Int32, b Enum8('a' = 1, 'b' = 2), c String, d Array(String)) ENGINE=Log").expect("query failed"); ch.query("INSERT INTO test_table (a, b, c, d) VALUES (10, 'a', 'test', ['abc', 'def']), (20, 'b', 'test2\ttest3\ntest4\rtest5', ['a\r\rbc', 'def', 'efg'])").expect("query failed"); ch.insert("INSERT INTO test_table (a, b, c, d)") // Insert by columns .column(vec![50, 60, 70, 80]) .column(vec!["a", "b", "a", "b"]) .column(vec!["str1", "str2", "str3", "str4"]) .column(vec![vec!["aaa", "bbb", "ccc"], vec!["ee", "ffff"], vec![], vec!["yo"]]) // Or rows .row((90, "a", "string", vec!["1", "2", "3"])).expect("can't insert row") .exec().expect("query failed"); assert_eq!(7, ch.select_row("SELECT count(*) FROM test_table").expect("query")[0].parse::<u32>().expect("count value")); for row in ch.select("SELECT * FROM test_table").expect("query failed") { println!("'{}', '{}', '{}', {}", &row[0], &row[1], &row[2], &row[3]); } ch.query("DROP TABLE test_table").expect("query failed");
Structs
ClickhouseClient | |
ClickhouseInsert | |
ClickhouseInsertRow | |
ClickhouseRow | |
ClickhouseRows |
Enums
Value |