Documentation
¶
Overview ¶
Package chclient is the ClickHouse transport layer. It wraps the official clickhouse-go driver and knows nothing about how credentials were acquired or how results are rendered.
Index ¶
- type AuthError
- type Client
- func (c *Client) Close() error
- func (c *Client) Connect(ctx context.Context) error
- func (c *Client) Database() string
- func (c *Client) Exec(ctx context.Context, sql string) (Stats, error)
- func (c *Client) Info() ServerInfo
- func (c *Client) Options() Options
- func (c *Client) Query(ctx context.Context, sql string) (*Rows, error)
- func (c *Client) QueryStrings(ctx context.Context, sql string) ([][]string, error)
- func (c *Client) Set(ctx context.Context, settings map[string]string) error
- func (c *Client) UseDatabase(ctx context.Context, database string) error
- type Column
- type ConnError
- type Options
- type Rows
- type ServerInfo
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthError ¶
type AuthError struct{ Err error }
AuthError reports that credentials could not be obtained or were rejected.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a session with one ClickHouse server. All statements of a session run on a single pooled connection, so session state set by statements the client does not track itself (SET ROLE, temporary tables) survives until that connection is re-established. The current database and plain settings are tracked by the client and survive reconnects.
func (*Client) Info ¶
func (c *Client) Info() ServerInfo
Info returns the server information gathered by Connect.
func (*Client) Query ¶
Query runs a statement and returns a streaming cursor over its result. The caller must Close the cursor before running another statement.
func (*Client) QueryStrings ¶
QueryStrings runs a query and returns every value rendered as a string. It buffers the whole result and is meant for small metadata queries.
type Column ¶
type Column struct {
Name string
Type string // ClickHouse type name, for example Nullable(DateTime64(3))
}
Column describes a result column.
type Options ¶
type Options struct {
Host string
Port int
Database string
Protocol string // config.ProtocolNative or config.ProtocolHTTP
Secure bool
InsecureSkipVerify bool
CACert string
// ClientVersion is reported to the server (visible in system.query_log).
ClientVersion string
}
Options describe the server to connect to.
func OptionsFrom ¶
OptionsFrom maps a resolved configuration to transport options.
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows is a forward-only cursor over a query result. Rows are streamed from the server; nothing is buffered beyond the driver's current block.
func (*Rows) Close ¶
Close releases the cursor and its connection. If the query was cancelled it is also stopped on the server.
func (*Rows) Columns ¶
Columns returns the result columns. It is empty for statements that return no result set (DDL and the like).
type ServerInfo ¶
type ServerInfo struct {
Version string
User string // the ClickHouse user the session is authenticated as
}
ServerInfo is what the server reported about itself and the session.