Read, write, or execute SQL against a DuckDB database.
DuckDB is included in the core Wrangles installation. Each operation opens its own connection; an in-memory database does not persist between independent connector calls. Use a database file when sharing data across operations.
read:
- duckdb:
database: products.duckdb
command: SELECT * FROM products WHERE category = ?
params: [Bearings]
| Parameter | Required | Data Type | Notes |
|---|---|---|---|
| database | ✓ | string | The database to connect to including the file path. Use ':memory:' for an in-memory database. |
| command | ✓ | string | SQL command to select data. Note - using variables here can make your recipe vulnerable to sql injection. Use params if using variables from untrusted sources. |
| columns | string, array | A list with a subset of the columns to import. This is less efficient than specifying in the command. | |
| params | array, object | Variables to pass to a parameterized query. |
write:
- duckdb:
database: products.duckdb
table: products
action: INSERT
| Parameter | Required | Data Type | Notes |
|---|---|---|---|
| database | ✓ | string | The database to connect to including the file path. Use ':memory:' for an in-memory database. |
| table | ✓ | string | The table to write to |
| action | string | INSERT appends, REPLACE recreates the table, FAIL errors if the table exists. Defaults to INSERT. Allowed values: INSERT, REPLACE, FAIL. |
|
| columns | string, array | A list of the columns to write to the table. If omitted, all columns will be written. |
run:
on_success:
- duckdb:
database: products.duckdb
command: DELETE FROM staging WHERE batch_id = ?
params: [completed-batch]
| Parameter | Required | Data Type | Notes |
|---|---|---|---|
| database | ✓ | string | The database to connect to including the file path. Use ':memory:' for an in-memory database. |
| command | ✓ | string, array | SQL command or a list of SQL commands to execute |
| params | array, object | Variables to pass to a parameterized query. |
Use params for SQL values. For writes, INSERT appends, REPLACE recreates the table, and FAIL rejects an existing table. REPLACE discards existing table data. Shared recipe options such as columns, not_columns, and if apply where supported by the recipe engine.