QuackDB.SQL (quackdb v0.3.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 an INSTALL extension; statement.

Builds a LOAD extension; statement.

Builds a SET name = value; statement.

Builds a SET GLOBAL name = value; 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()}

install(extension)

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

Builds an INSTALL extension; statement.

literal(value)

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

load(extension)

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

Builds a LOAD extension; statement.

set(name, value)

@spec set(atom() | String.t(), parameter()) :: iodata()

Builds a SET name = value; statement.

set_global(name, value)

@spec set_global(atom() | String.t(), parameter()) :: iodata()

Builds a SET GLOBAL name = value; statement.