XU XUv0.8.8
中文

API

#github.com/xulang-org/packages/clickhouse

import: clickhouse #github.com/xulang-org/packages/clickhouse

counts: 5 fns, 15 methods, 3 types, 0 consts, 0 ifaces

ClickHouse High-Performance Analytical Database (OLAP) Driver for Xu Features Native HTTP/1.1 REST communication via Xu standard library. SQL query execution with high-throughput batch insert. Connection pooling via reusable TCP socket channels. Full compatibility with ClickHouse 22.x/23.x/24.x+.

github.com/xulang-org/packages · 0.1.1 · Install and use

open

XuAPI
pub fn open(endpoint string, user string, password string, database string) Client

Purpose

ClickHouse High-Performance Analytical Database (OLAP) Driver for Xu Features Native HTTP/1.1 REST communication via Xu standard library. SQL query execution with high-throughput batch insert. Connection pooling via reusable TCP socket channels. Full compatibility with ClickHouse 22.x/23.x/24.x+.

Parameters

endpoint string
endpoint (string)
user string
user (string)
password string
password (string)
database string
database (string)

Returns

Client — a value of this type

open_pool

XuAPI
pub fn open_pool(endpoint string, user string, password string, database string, max_idle int) Pool

Purpose

Open pool.

Parameters

endpoint string
endpoint (string)
user string
user (string)
password string
password (string)
database string
database (string)
max_idle int
max_idle (int)

Returns

Pool — a value of this type

struct Response

XuAPI
pub struct Response {
    pub status_code int
    pub body string
}

Purpose

Public struct `Response`.

Parameters

status_code int
field (int)
body string
body

struct Client

XuAPI
pub struct Client {
    pub host string
    pub port int
    pub user string
    pub password string
    pub database string
}

Purpose

Public struct `Client`.

Parameters

host string
host
port int
port
user string
field (string)
password string
field (string)
database string
field (string)

new_client

XuAPI
pub fn new_client(endpoint string, user string, password string, database string) Client

Purpose

Construct client.

Parameters

endpoint string
endpoint (string)
user string
user (string)
password string
password (string)
database string
database (string)

Returns

Client — a value of this type

parse_tsv

XuAPI
pub fn parse_tsv(raw string) [][]string

Purpose

Parse as tsv.

Parameters

raw string
raw (string)

Returns

[][]string — slice result

(&mut Client) request

XuAPI
pub fn (c &mut Client) request(sql_query string) Response

Purpose

Call `request` on `&mut Client`. Throws on failure.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
sql_query string
sql_query (string)

Returns

Response — a value of this type

struct Pool

XuAPI
pub struct Pool {
    pub host string
    pub port int
    pub user string
    pub password string
    pub database string
    pub state chan pool.State
    pub max_idle int
}

Purpose

Connection Pool for ClickHouse. Manages reusable TCP socket connections.

Parameters

host string
host
port int
port
user string
field (string)
password string
field (string)
database string
field (string)
state chan pool.State
field (channel; type chan pool.State)
max_idle int
field (int)

new_pool

XuAPI
pub fn new_pool(endpoint string, user string, password string, database string, max_idle int) Pool

Purpose

Construct pool.

Parameters

endpoint string
endpoint (string)
user string
user (string)
password string
password (string)
database string
database (string)
max_idle int
max_idle (int)

Returns

Pool — a value of this type

(&Pool) get

XuAPI
pub fn (p &Pool) get() Client

Purpose

Call `get` on `&Pool`.

Parameters

p &Pool
receiver &Pool (borrow)

Returns

Client — a value of this type

(&Pool) dup

XuAPI
pub fn (p &Pool) dup() Pool

Purpose

Call `dup` on `&Pool`.

Parameters

p &Pool
receiver &Pool (borrow)

Returns

Pool — a value of this type

(&Pool) get_conn

XuAPI
pub fn (p &Pool) get_conn() int

Purpose

Method on `&Pool`: read conn.

Parameters

p &Pool
receiver &Pool (borrow)

Returns

int — a value of this type

(&Pool) put_conn

XuAPI
pub fn (p &Pool) put_conn(fd int)

Purpose

Method on `&Pool`: put connection.

Parameters

p &Pool
receiver &Pool (borrow)
fd int
file descriptor (int)

(&Pool) discard_conn

XuAPI
pub fn (p &Pool) discard_conn(fd int)

Purpose

Method on `&Pool`: discard connection.

Parameters

p &Pool
receiver &Pool (borrow)
fd int
file descriptor (int)

(&Pool) exec

XuAPI
pub fn (p &Pool) exec(sql_query string) int

Purpose

Call `exec` on `&Pool`. Throws on failure.

Parameters

p &Pool
receiver &Pool (borrow)
sql_query string
sql_query (string)

Returns

int — a value of this type

(&Pool) query

XuAPI
pub fn (p &Pool) query(sql_query string) string

Purpose

Call `query` on `&Pool`. Throws on failure.

Parameters

p &Pool
receiver &Pool (borrow)
sql_query string
sql_query (string)

Returns

string — result string

(&Pool) query_tsv

XuAPI
pub fn (p &Pool) query_tsv(sql_query string) [][]string

Purpose

Method on `&Pool`: query tsv. Throws on failure.

Parameters

p &Pool
receiver &Pool (borrow)
sql_query string
sql_query (string)

Returns

[][]string — slice result

(&Pool) close

XuAPI
pub fn (p &Pool) close()

Purpose

Method on `&Pool`: close the resource.

Parameters

p &Pool
receiver &Pool (borrow)

(&mut Client) exec

XuAPI
pub fn (c &mut Client) exec(sql_query string) int

Purpose

Call `exec` on `&mut Client`. Throws on failure.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
sql_query string
sql_query (string)

Returns

int — a value of this type

(&mut Client) query

XuAPI
pub fn (c &mut Client) query(sql_query string) string

Purpose

Call `query` on `&mut Client`. Throws on failure.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
sql_query string
sql_query (string)

Returns

string — result string

(&mut Client) query_tsv

XuAPI
pub fn (c &mut Client) query_tsv(sql_query string) [][]string

Purpose

Method on `&mut Client`: query tsv. Throws on failure.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
sql_query string
sql_query (string)

Returns

[][]string — slice result

(&mut Client) ping

XuAPI
pub fn (c &mut Client) ping() bool

Purpose

Call `ping` on `&mut Client`.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)

Returns

bool — true or false

(&mut Client) insert

XuAPI
pub fn (c &mut Client) insert(table string, values_sql string) int

Purpose

Call `insert` on `&mut Client`.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
table string
table (string)
values_sql string
values_sql (string)

Returns

int — a value of this type