Skip to main content

Querying local DuckDB databases and files

MotherDuck seamlessly integrates with DuckDB allowing you to use its full power to explore data on your laptop.

Explore any DuckDB file as an attached database:

--Querying a data stored in a local duckdb database
> ATTACH 'local_path.db' AS a_duck_db;
SELECT * FROM a_duck_db.local_table;

DuckDB can also directly query many of your favorite file formats:

--Querying stored in csv
> SELECT * FROM '/path/to/local_file.csv';

--Querying a parquet file
> SELECT * FROM '/path/to/local_file.parquet';

--Query a json file
> SELECT * FROM '/path/to/local_file.json';

DuckDB can also directly query python dataframes and apache arrow datasets:

import duckdb
import pandas as pd
test_df = pd.DataFrame.from_dict({"i":[1, 2, 3, 4], "j":["one", "two", "three", "four"]})
duckdb.sql('SELECT * FROM test_df').fetchall()