QuackDB.SQL (quackdb v0.2.0)

Copy Markdown View Source

Client-side SQL parameter formatting for DuckDB Quack queries.

DuckDB's current Quack protocol request shape does not expose server-side bind parameters. QuackDB therefore formats positional ? placeholders as DuckDB SQL literals before sending a PrepareRequest.

The formatter scans SQL and ignores placeholders inside quoted strings and SQL comments. It supports conservative scalar values and raises QuackDB.Error for unsupported parameter shapes rather than producing lossy SQL.

Summary

Functions

Builds a CALL function(args..., option = value...); statement.

Builds a LOAD extension; statement.

Types

parameter()

@type parameter() ::
  nil
  | boolean()
  | integer()
  | float()
  | String.t()
  | Decimal.t()
  | Date.t()
  | Time.t()
  | NaiveDateTime.t()
  | DateTime.t()
  | QuackDB.Interval.t()
  | {:blob, binary()}
  | {:interval, integer(), integer(), integer()}
  | [parameter()]

Functions

call(function, positional_args \\ [], named_args \\ [])

@spec call(atom() | String.t(), [parameter()], keyword(parameter())) :: iodata()

Builds a CALL function(args..., option = value...); statement.

format(statement, params)

@spec format(iodata(), [parameter()]) ::
  {:ok, String.t()} | {:error, QuackDB.Error.t()}

literal(value)

@spec literal(parameter()) :: {:ok, iodata()} | {:error, QuackDB.Error.t()}

load(extension)

@spec load(atom() | String.t()) :: iodata()

Builds a LOAD extension; statement.