motherduck-connect

Configure MotherDuck database connections via PG endpoint, native DuckDB API, or JDBC.

Updated Oct 15, 2019
One-click install
npx skills add https://github.com/kkkaoru/dotfiles --skill motherduck-connect-kkkaoru
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: motherduck-connect
Source: https://github.com/kkkaoru/dotfiles/tree/main/.agents/skills-stroage/motherduck-connect
Command: npx skills add https://github.com/kkkaoru/dotfiles --skill motherduck-connect-kkkaoru

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Setting up connectivity to MotherDuck involves choosing between the Postgres endpoint, native DuckDB API, pg_duckdb, and JDBC, each with different authentication, SSL, and scaling requirements. This Skill guides that selection and provides working connection code so applications connect correctly on the first attempt. ## Core Features & Use Cases - Connection Method Selection: Decision guidance for PG endpoint, native DuckDB API, pg_duckdb, and DuckDB-WASM based on workload type. - Ready-to-Use Code Examples: Python (psycopg2, SQLAlchemy, duckdb) and Node.js (pg, @duckdb/node-api) snippets with SSL and token handling. - Read Scaling & Session Affinity: Configuration of read-scaling tokens, session_hint, and attach modes for high-concurrency read workloads. - Use Case: A backend engineer building a serverless analytics API uses the PG endpoint connection string with environment-managed tokens, verifies connectivity with SELECT 1, and adds session_hint-based read scaling when concurrent read traffic grows. ## Quick Start Ask the assistant to connect your application to MotherDuck and it will recommend the right connection method with working code.

Frequently Asked Questions about motherduck-connect

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I connect to MotherDuck from a Python application?

Use psycopg2 or SQLAlchemy against the PG endpoint with your MotherDuck token as the password and sslmode=verify-full, or use the duckdb package with duckdb.connect("md:my_database") for native API access. Store the token in the MOTHERDUCK_TOKEN environment variable.

MotherDuck PG endpoint vs native DuckDB API: which should I use?

Use the PG endpoint for backend apps, BI tools, and serverless runtimes needing PostgreSQL wire compatibility. Use the native DuckDB API when you need local file access, hybrid local/cloud execution, or full DuckDB configuration control.

Does the MotherDuck PG endpoint support PostgreSQL features?

No. The PG endpoint executes DuckDB SQL only and does not support pg_* functions, indexes, sequences, stored procedures, LISTEN/NOTIFY, or advisory locks. It also lacks local file access and dual execution.

How do I set up read scaling for concurrent MotherDuck queries?

Create a read-scaling token and connect with a stable session_hint per user or tenant, plus access_mode=read_only. Read-scaling replicas are eventually consistent, with a default pool of 4 replicas expandable to 16.

Why does my MotherDuck connection fail with SSL errors?

The PG endpoint requires SSL. Set sslmode=verify-full and provide sslrootcert, for example using certifi.where() in Python, or configure ssl: { rejectUnauthorized: true } in the Node.js pg client.