Skip to main content

DuckDB Source

Read tables/views from a local DuckDB database file (or an in-memory DB) as a drt sync source. Bundled in drt-core — no extra install.

Profile (~/.drt/profiles.yml)​

warehouse:
type: duckdb
database: warehouse.duckdb # file path, or ":memory:"

Configuration​

FieldTypeDefaultDescription
type"duckdb"—Required
databasestring:memory:Path to the .duckdb file, or :memory: for an ephemeral in-process DB

Notes​

  • (core) — DuckDB ships with drt-core; nothing extra to install.
  • Each sync's model SQL is executed against this database; reference any table or view it contains.
  • drt init --template duckdb_to_rest scaffolds a runnable DuckDB → REST project.
  • :memory: only holds data created in the same process, so it's for tests/demos rather than persisted pipelines.

References​

Streaming extraction (#765)​

Rows are read in fetch_size batches rather than materialised whole, so peak memory tracks the batch instead of the result set — roughly a 3.5× reduction on a 300k-row extract. Measured figures for every source are collected in Extraction memory.

"It's a local file" does not make buffering free: the cost this removes is holding every row as a Python object, which a local file incurs just as readily as a remote warehouse.

DuckDB uses an explicit fetchmany loop rather than iterating, because its result object has no __iter__.

fetch_size: 10000 # rows per batch (default: 10000)

Memory scales with fetch_size x row width, not row count — lower it for very wide rows, not for big tables.