Duckex (duckex v0.1.0)
A naive DuckDB binding for Elixir via Rust port. Provides basic functionality to execute SQL queries against DuckDB, primarily for testing DuckLake functionality.
Summary
Functions
Install extensions for DuckDB.
Prepares query.
Prepares query and returns the prepared query or raises Duckex.Error
if there is an error. See prepare/3.
Prepares and executes query in the single step.
Prepares and executes query in the single step and returns the prepared query
or raises Duckex.Error if there is an error. See prepare_execute/5.
Starts the DuckDB process.
Types
Functions
See DBConnection.close/3.
@spec install_extensions([extension], [connection_option()]) :: :ok | {:error, term()} when extension_opt: {:source, :default | :core | :nightly | String.t()} | {:force, boolean()}, extension: atom() | {atom(), [extension_opt]}
Install extensions for DuckDB.
This will spawn temporary connection and will install extensions within that connection. After that each new DuckDB instance is capable of using that extensions.
It is a helper function to provide a cleaner syntax - extensions use similar
syntax to Mix.install/2 and are either:
- atom containing name of the extension to be installed
- tuple in form of
{atom(), opts}
Options
:source- source from which the extension should be installed. Supported options are::default(used when option is not specified) - uses default registry configured for connection:core:nightly- equivalent ofcore_nightlyfrom DuckDB- String representing URL from which the extension should be installed
:force- forcefully install extension, even when it is already installed. Can be used to update extension.
@spec prepare(DBConnection.conn(), String.t(), list()) :: {:ok, Duckex.Query.t()} | {:error, Duckex.Error.t()}
Prepares query.
@spec prepare!(DBConnection.conn(), String.t(), list()) :: Duckex.Query.t()
Prepares query and returns the prepared query or raises Duckex.Error
if there is an error. See prepare/3.
@spec prepare_execute(DBConnection.conn(), String.t(), list(), list()) :: {:ok, Duckex.Query.t(), Duckex.Result.t()} | {:error, Duckex.Error.t()}
Prepares and executes query in the single step.
@spec prepare_execute!(DBConnection.conn(), String.t(), list(), list()) :: {Duckex.Query.t(), Duckex.Result.t()}
Prepares and executes query in the single step and returns the prepared query
or raises Duckex.Error if there is an error. See prepare_execute/5.
@spec query(DBConnection.conn(), String.t(), list(), list()) :: {:ok, Duckex.Result.t()} | {:error, Duckex.Error.t()}
@spec query!(DBConnection.conn(), String.t(), list(), list()) :: Duckex.Result.t()
@spec rollback(DBConnection.t(), reason :: any()) :: no_return()
@spec start_link([connection_option()]) :: Supervisor.on_start()
Starts the DuckDB process.
Options
Duckex provides some helper options to setup connection before it is available.
:secrets- secrets to be set up before instance is made ready. It is list of tuples where first element is name of secret and second is keyword lists containing secret details.:attach- list of tuples where first element is the attach string and the second one is list of options, optional 3rd element contains connection options, seeattach/4.
Secrets are set up before attaching connections, so you can use these secrets for attaching (like S3 secrets).