Skip to content

Zig1375/SwiftClickHouse

Repository files navigation

Build Status

Introduction

ClickHouse Swift client library.

Here is an example on how to use it:

Connection

import SwiftClickHouse;

do {
    // let conn = try Connection(); /// Will use defaults values
    let conn = try Connection(host : "localhost", port : 9000, database : "default", user : "default", password : "", compression : .Disable);
    

    // YOUR CODE HERE
}  catch ClickHouseError.Error(let code, let display_text, let exception) {
    print("\(errno) : \(error)");
} catch {
    print("Unknown error");
}

Query

if let result = try? connect.query(sql: "select * from test") {
    let row = result!.fetchRow()!;
    print(row["a"]!.double)
    print(result!.description);
}

Insert

let block = ClickHouseBlock();
block.append(name: "a", 100.500);

if let _ = try? connect.insert(table: "test", block: block) {
    // Success
}

Attention

Compression not implemented now.