Skip to main content
DuckDB Logo

Overview

Use DuckDB as a destination in Mage to write structured data to local DuckDB database files. DuckDB is an embedded analytical database that runs in-process, making it ideal for fast local analytics, data staging, or lightweight data processing workflows. This destination is perfect for scenarios where you need to quickly analyze data locally before pushing to a larger data warehouse, or for building lightweight analytics pipelines.

Required Configuration

You must enter the following configuration when writing to a DuckDB destination:
KeyDescriptionExample ValueRequired
file_pathAbsolute file path to the .duckdb file where data will be saved./home/src/default_repo/mage_output.duckdb
if_existsWhat to do if the table already exists: replace, append, or fail.replace

Configuration Options

if_exists Values

ValueDescription
replaceOverwrites the existing table with new data. The table will be recreated on each pipeline run.
appendAdds new data to the existing table. Existing rows remain unchanged.
failRaises an error if the table already exists. Useful for preventing accidental overwrites.

Notes

  • Embedded Database: DuckDB is an embedded database. The file is local to the machine or container where Mage is running.
  • Pandas Integration: Supports writing pandas DataFrames directly to tables in a .duckdb file.
  • File Path: Use absolute paths to ensure the file is created in the correct location.
  • Performance: DuckDB is optimized for analytical queries and can handle large datasets efficiently.
  • Use Cases: Ideal for fast, local analytics or staging data before pushing to a warehouse.

Sample Configuration

file_path: /home/src/default_repo/mage_output.duckdb
if_exists: replace