Skip to content

duckdb

relationalai.config.connections

DuckDB connection configuration.

This module defines a small Pydantic model for configuring a DuckDB connection. You typically use it through the create_config factory function by adding a DuckDB connection entry under the connections keyword argument.

The connection entry can be provided as either:

  • A Python dict (recommended for config files), or
  • An instance of DuckDBConnection (useful when building configs programmatically).

Calling DuckDBConnection.get_session creates and caches the underlying DuckDBPyConnection.

Configure an in-memory DuckDB connection:

>>> from relationalai.config import Config
>>> cfg = Config(connections={"local": {"type": "duckdb", "path": ":memory:"}})

Configure a file-backed DuckDB connection:

>>> from relationalai.config import Config
>>> cfg = Config(connections={"local": {"type": "duckdb", "path": "./my.db"}})

Classes exposed by this module.