Cross-Database Federation

dadbod-grip uses DuckDB as a federation hub. Attach any combination of Postgres, MySQL, SQLite, and MotherDuck databases alongside local files, remote URLs, and S3 paths. Query all of them in a single SQL statement.

How it works

Start with a DuckDB connection (file or memory), then attach external sources:

:GripAttach postgres:dbname=production host=db.internal user=app  prod
:GripAttach sqlite:archive.db  archive
:GripAttach md:analytics  cloud

Each attachment gets a schema alias. Use that alias as a SQL prefix:

SELECT
  prod.customers.email,
  archive.orders.amount,
  cloud.segments.label
FROM prod.customers
JOIN archive.orders ON archive.orders.customer_id = prod.customers.id
JOIN cloud.segments ON cloud.segments.customer_id = prod.customers.id
WHERE prod.customers.plan = 'enterprise'

Execute from the query pad with <C-CR>. Results open as an editable grip grid.

Required extensions

DuckDB installs the necessary scanner extension automatically when you attach:

Attachment prefixExtension installed
postgres:postgres_scanner
sqlite:sqlite_scanner
md:MotherDuck cloud client

You do not need to run INSTALL or LOAD manually.

File attachments in federation

Add remote or local files directly in your SQL without attaching them:

SELECT local.*, remote.value
FROM prod.customers local
JOIN read_parquet('s3://my-bucket/enrichment.parquet') remote
  ON remote.customer_id = local.id

Or open a file as a named connection to keep it persistent:

:GripOpen s3://my-bucket/data.parquet

Persisted attachments

Attachments persist in .grip/connections.json and restore automatically when you reconnect to the same DuckDB file. The sidebar shows each attached database as a separate section with its own table list.

From the schema sidebar, two keymaps manage attachments without leaving the buffer:

KeyAction
gaAttach an external database (prompts for URL and alias)
gdDetach an attached database (picker)

The sidebar shows each attached database as a separate section with its own table list and PK/FK markers.

Detach

:GripDetach

Select the attachment to remove from a picker. Or press gd in the schema sidebar.

Auto-restore on reconnect

Attachments persist in .grip/connections.json. When you reconnect to the same DuckDB file in a future session, all previous attachments restore automatically. You do not need to re-run :GripAttach each time.

MotherDuck

MotherDuck is a cloud DuckDB service. Attach it the same way as any other source:

:GripAttach md:my_database  cloud

Set MOTHERDUCK_TOKEN in your shell environment. The md: prefix tells DuckDB to use the MotherDuck client extension, which installs automatically on first use.