This project demonstrates how to connect to MotherDuck from Python using DuckDB.
-
Install Dependencies
pip install duckdb --upgrade
-
Set Your MotherDuck Token
Either export it as an environment variable:export MOTHERDUCK_TOKEN=<your_motherduck_token>
Or include it in the connection string (less secure):
con = duckdb.connect("md:my_db?token=<your_motherduck_token>")
- Make sure you have a valid MotherDuck account and token.
- MotherDuck queries work just like DuckDB queries, so you can use all standard SQL commands.
- If you run into issues, check your MotherDuck token or review the MotherDuck Docs for more details.
