Huginn (Huginn v0.4.0)
View SourceClickHouse client for Elixir using gRPC.
Huginn provides a simple interface for querying ClickHouse databases over gRPC with connection pooling and streaming support.
Configuration
Configure ClickHouse connection in your config.exs:
config :huginn, :clickhouse,
host: "localhost",
port: 9100,
database: "default",
auth: {:password, "default", ""},
pool_size: 5Usage
# Simple query
{:ok, result} = Huginn.query("SELECT * FROM system.tables LIMIT 10")
# Get results as maps
maps = Huginn.Clickhouse.Result.to_maps(result)
# Insert data
data = [["john", "25"], ["jane", "30"]]
{:ok, _} = Huginn.insert("INSERT INTO users (name, age) VALUES", data)
# Stream large results
Huginn.stream_query("SELECT * FROM large_table")
|> Enum.each(&process_row/1)Telemetry
Requests emit [:huginn, :query, :start | :stop | :exception] events. Attach
the built-in logger with attach_default_logger/1, or your own handler — see
Huginn.Clickhouse.Telemetry for the full event reference.
Retries
query/2 and insert/3 accept :retries and :retry_backoff options to
retry transient transport failures with exponential backoff. Retries are
off by default; ClickHouse query errors are never retried. See
Huginn.Clickhouse.Retry.
Summary
Functions
Attaches the built-in Logger handler for Huginn telemetry events.
Cancels a running query by ID.
Cancels queries matching a condition.
Detaches the built-in telemetry logger.
Inserts data using a single request.
Inserts data using streaming input for large datasets.
Pings the ClickHouse server.
Executes a query and returns the result.
Executes a query and raises on error.
Lists currently running queries.
Opens a bidirectional streaming connection.
Streams rows as maps from a query result.
Executes a query and returns a stream of results.
Streams rows from a query result.
Functions
Attaches the built-in Logger handler for Huginn telemetry events.
Cancels a running query by ID.
See Huginn.Clickhouse.Client.cancel/2 for options.
Cancels queries matching a condition.
See Huginn.Clickhouse.Client.cancel_where/2 for options.
Detaches the built-in telemetry logger.
Inserts data using a single request.
See Huginn.Clickhouse.Client.insert/3 for options.
Inserts data using streaming input for large datasets.
See Huginn.Clickhouse.Client.insert_stream/3 for options.
Pings the ClickHouse server.
See Huginn.Clickhouse.Client.ping/1 for options.
Executes a query and returns the result.
See Huginn.Clickhouse.Client.query/2 for options.
Executes a query and raises on error.
See Huginn.Clickhouse.Client.query!/2 for options.
Lists currently running queries.
See Huginn.Clickhouse.Client.running_queries/1 for options.
Opens a bidirectional streaming connection.
See Huginn.Clickhouse.Client.stream_io/1 for options.
Streams rows as maps from a query result.
See Huginn.Clickhouse.Client.stream_maps/2 for options.
Executes a query and returns a stream of results.
See Huginn.Clickhouse.Client.stream_query/2 for options.
Streams rows from a query result.
See Huginn.Clickhouse.Client.stream_rows/2 for options.