Skip to main content

Duckdb

@zocc/duckdbv2026.05.21.6· 1d agoMODELS·DATASTORES
01README

DuckDB integration for swamp: query model for ad-hoc SQL, and a datastore backend that stores swamp runtime data in a DuckDB database file with row-based distributed locking. Embedded, local-only — no network dependency.

Model

Run SQL queries against local DuckDB databases, list tables, inspect schemas, and export query results as structured data resources. bash swamp model create @zocc/duckdb mydb swamp model method run mydb list_tables --input database=/path/to/data.duckdb swamp model method run mydb query --input database=/path/to/data.duckdb --input sql="SELECT * FROM t LIMIT 10" swamp model method run mydb summarize --input database=/path/to/data.duckdb

Datastore

Use DuckDB as the storage backend for swamp runtime data.

  type: "@zocc/duckdb"
  config:
    database: "/path/to/swamp.duckdb"
    schema: "swamp"

bash export SWAMP_DATASTORE='@zocc/duckdb:{"database":"/data/swamp.duckdb"}'

Required Tools

02Models1
@zocc/duckdbv2026.05.21.2query.ts
fn list_tables(database: string)
List all tables with their column names and types in a DuckDB database
ArgumentTypeDescription
databasestringPath to the DuckDB database file
fn query(database: string, sql: string, limit: number)
Execute a SQL query against a DuckDB database and return structured results
ArgumentTypeDescription
databasestringPath to the DuckDB database file
sqlstringSQL query to execute
limitnumberMaximum number of rows to return (0 = unlimited)
fn summarize(database: string)
Get a high-level summary of all tables in a DuckDB database with row counts
ArgumentTypeDescription
databasestringPath to the DuckDB database file
fn import_data(database: string, source: string, table: string, format: string, create_table: boolean, delimiter: string, header: boolean)
Import data from a file (CSV, JSON, Parquet) into a DuckDB table
ArgumentTypeDescription
databasestringPath to the DuckDB database file
sourcestringPath or URL to the source file (CSV, JSON, NDJSON, or Parquet)
tablestringTarget table name to import into
formatstringSource format: csv, json, ndjson, parquet, or auto (detect from extension)
create_tablebooleanCREATE TABLE IF NOT EXISTS before importing
delimiterstringColumn delimiter for CSV files (default: comma)
headerbooleanWhether the source CSV has a header row
fn export_data(database: string, destination: string, sql?: string, table?: string, format: string, delimiter: string, header: boolean)
Export query results or an entire table to CSV, JSON, or Parquet
ArgumentTypeDescription
databasestringPath to the DuckDB database file
destinationstringOutput file path (extension determines format: .csv, .json, .parquet)
sql?stringSQL query to export (use instead of table)
table?stringTable name to export (use instead of sql)
formatstringOutput format: csv, json, parquet, or auto (detect from destination extension)
delimiterstringColumn delimiter for CSV output (default: comma)
headerbooleanWhether to include header row in CSV output

Resources

tables(1h)— List of tables and their column schemas in a database
query_result(1h)— Results of a SQL query against a DuckDB database
summary(1h)— High-level summary of all tables in a database
import_result(1h)— Result of importing data into a DuckDB table
export_result(1h)— Result of exporting data from a DuckDB database
03Datastores1
DuckDB Datastoreconfigurable
@zocc/duckdb-datastoredatastores/duckdb_datastore/mod.ts

Stores swamp runtime data in a DuckDB database file with row-based distributed locking. Embedded, local-only — no network dependency.

Config Fields

FieldTypeDescription
databasestringPath to the DuckDB database file. Use ':memory:' for an in-memory database.
schemastringDuckDB schema for swamp tables
accessModeenumDatabase access mode: read_write (default) or read_only
04Previous Versions3
2026.05.21.5May 21, 2026
2026.05.21.4May 21, 2026
2026.05.21.3May 21, 2026

v2026.05.21.3: DuckDB query model + datastore backend

Model methods: list_tables, query, summarize, import_data, export_data Datastore: embedded runtime storage with nonce-based locking Formats: CSV, JSON, NDJSON, Parquet (import + export) Platforms: linux-x86_64, linux-aarch64, darwin-x86_64, darwin-aarch64

05Stats
Downloads
0
Archive size
16.5 KB

Not yet scored.

A score will be generated the next time this extension is published. The owner can also trigger scoring manually.

06Platforms
07Labels