API
#github.com/xulang-org/packages/clickhouse
Xu 0.8.8 API
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
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
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
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
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
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
pub fn parse_tsv(raw string) [][]string
Purpose
Parse as tsv.
Parameters
raw string- raw (string)
Returns
[][]string — slice result
(&mut Client) request
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
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
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
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
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
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
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
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
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
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
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
Purpose
Method on `&Pool`: close the resource.
Parameters
p &Pool- receiver &Pool (borrow)
(&mut Client) exec
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
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
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
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
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