DuckdbEx (DuckdbEx v0.2.0)
View SourceDuckDB Elixir Client - A 100% faithful port of the Python duckdb client.
This library provides Elixir bindings to DuckDB, an in-process SQL OLAP database management system. It mirrors the Python duckdb API for compatibility and ease of migration.
Reference: duckdb-python for API compatibility
Quick Start
# Connect to an in-memory database
{:ok, conn} = DuckdbEx.connect()
# Execute a query
{:ok, result} = DuckdbEx.execute(conn, "SELECT 42 as answer")
# Close the connection
DuckdbEx.close(conn)Architecture
This implementation uses the DuckDB CLI binary managed through erlexec, providing a simpler alternative to NIF-based approaches while covering core SQL and Relation behaviors.
Modules
DuckdbEx.Connection- Connection managementDuckdbEx.Port- DuckDB CLI process managementDuckdbEx.Exceptions- Exception types
Future Modules (to be implemented)
DuckdbEx.Type- Type systemDuckdbEx.Expression- Expression helpers
Summary
Functions
Closes a database connection.
Opens a connection to a DuckDB database.
Returns the current default connection, creating one if needed.
Executes a SQL query.
Sets the default connection used by module-level helpers.
Functions
Closes a database connection.
This is a convenience function that delegates to DuckdbEx.Connection.close/1.
Examples
{:ok, conn} = DuckdbEx.connect()
:ok = DuckdbEx.close(conn)
Opens a connection to a DuckDB database.
This is a convenience function that delegates to DuckdbEx.Connection.connect/2.
Examples
{:ok, conn} = DuckdbEx.connect()
{:ok, conn} = DuckdbEx.connect(:memory)
{:ok, conn} = DuckdbEx.connect("/path/to/db.duckdb")
Returns the current default connection, creating one if needed.
Executes a SQL query.
This is a convenience function that delegates to DuckdbEx.Connection.execute/3.
Examples
{:ok, conn} = DuckdbEx.connect()
{:ok, result} = DuckdbEx.execute(conn, "SELECT 1")
Sets the default connection used by module-level helpers.