Introducing Flights: agent-native data pipelines in MotherDuckJoin the livestream

Skip to main content

Supabase

Supabase is a Postgres platform for building applications with a managed database, APIs, authentication, storage, and realtime features. Supabase's documented DuckDB Wrapper can query MotherDuck from a Supabase Postgres database through a foreign data wrapper.

How it works with MotherDuck

  1. Enable the Supabase Wrappers extension.
  2. Create the duckdb_wrapper foreign data wrapper.
  3. Store a MotherDuck token in Supabase Vault, then create a foreign server with type 'md', the MotherDuck database name, and the Vault-backed token option.
  4. Create a schema for the foreign tables.
  5. Import a MotherDuck schema, such as main, into Supabase and query the imported foreign tables from Postgres.
create extension if not exists wrappers with schema extensions;

create foreign data wrapper duckdb_wrapper
handler duckdb_fdw_handler
validator duckdb_fdw_validator;

create server duckdb_server_md
foreign data wrapper duckdb_wrapper
options (
type 'md',
database 'my_db',
vault_motherduck_token '<vault_secret_id>'
);

create schema if not exists duckdb;

import foreign schema "main"
from server duckdb_server_md into duckdb;

select *
from duckdb.my_table
limit 10;

The Supabase DuckDB Wrapper is a read path into MotherDuck: it supports querying foreign tables, including where, order by, and limit pushdown, but does not support inserts, updates, deletes, or truncates through the foreign tables.