View Source Ch (Ch v0.1.1)

ClickHouse driver for Elixir.

Ch uses HTTP interface and RowBinaryWithTypesAndNames format for all statements except for INSERT. In order to enable custom formats, INSERT statements require the parameters to be encoded prior to calling query/4.

Link to this section Summary

Functions

Returns a supervisor child specification for a DBConnection pool.

Runs a query and returns the result as {:ok, %Ch.Result{}} or {:error, %Ch.Error{}} if there was a database error.

Runs a query and returns the result or raises Ch.Error if there was an error. See query/4.

Start the connection process and connect to ClickHouse.

Link to this section Functions

Returns a supervisor child specification for a DBConnection pool.

Link to this function

query(conn, statement, params \\ [], opts \\ [])

View Source
@spec query(
  DBConnection.conn(),
  iodata(),
  {:raw, iodata()} | Enumerable.t(),
  Keyword.t()
) ::
  {:ok, Ch.Result.t()} | {:error, Exception.t()}

Runs a query and returns the result as {:ok, %Ch.Result{}} or {:error, %Ch.Error{}} if there was a database error.

options

Options

  • :timeout - Query request timeout
  • :settings - Keyword list of settings
  • :database - Database
  • :username - Username
  • :password - User password
Link to this function

query!(conn, statement, params \\ [], opts \\ [])

View Source
@spec query!(
  DBConnection.conn(),
  iodata(),
  {:raw, iodata()} | Enumerable.t(),
  Keyword.t()
) ::
  Ch.Result.t()

Runs a query and returns the result or raises Ch.Error if there was an error. See query/4.

Start the connection process and connect to ClickHouse.

options

Options

* `:hostname` - server hostname, defaults to `localhost`
* `:port` - HTTP port, defualts to `8123`
* `:scheme` - HTTP scheme, defaults to `"http"`
* `:database` - Database, defaults to `"default"`
* `:username` - Username
* `:password` - User password
* `:settings` - Keyword list of settings
* `:timeout` - HTTP receive timeout in milliseconds