Installing & Setting Up DuckDB
DuckDB ships as a single-file, dependency-free binary or library for every major language. There is no daemon to start and no configuration file required to get going.
Command-Line Interface
# macOS (Homebrew)brew install duckdb
# Linux / macOS (official install script)curl https://install.duckdb.org | sh
# Or download the prebuilt binary directly# https://duckdb.org/docs/installation/Launch it:
duckdbD SELECT version();┌───────────┐│ "library_version" │├───────────┤│ v1.1.x │└───────────┘Type .help inside the shell for dot-commands (.tables, .schema, .mode, .import, etc.) — most SQLite CLI users will feel immediately at home.
Python
pip install duckdbimport duckdb
# Query directly, no connection object needed for one-off queriesduckdb.sql("SELECT 42 AS answer").show()
# Or create an explicit connection (recommended for real applications)con = duckdb.connect("analytics.duckdb") # persisted to disk# con = duckdb.connect() # in-memory, ephemeral
con.execute("CREATE TABLE events (id INTEGER, name VARCHAR)")con.execute("INSERT INTO events VALUES (1, 'signup'), (2, 'purchase')")print(con.execute("SELECT * FROM events").fetchall())Node.js
npm install @duckdb/node-apiimport { DuckDBInstance } from '@duckdb/node-api';
const instance = await DuckDBInstance.create('analytics.duckdb');const connection = await instance.connect();const reader = await connection.runAndReadAll('SELECT 42 AS answer');console.log(reader.getRows());Official clients also exist for R, Java, Go, Rust, C/C++, WASM (browser), and ODBC/JDBC — the SQL surface and file format are identical across all of them.
In-Memory vs. Persistent Databases
| Mode | How | Use case |
|---|---|---|
| In-memory | duckdb.connect() / no filename | One-off scripts, tests, ephemeral analysis |
| Persistent file | duckdb.connect("mydb.duckdb") | Anything you want to reopen later — a single portable file |
A persisted DuckDB database is one file on disk — back it up, copy it, or ship it like any other artifact. There’s no separate data directory or config to keep in sync.
Sanity-Check Your Setup
INSTALL httpfs; -- confirms extension download/network access worksLOAD httpfs;SELECT * FROM 'https://raw.githubusercontent.com/duckdb/duckdb/main/data/parquet-testing/userdata1.parquet' LIMIT 5;If that returns rows, your installation, network access, and extension system are all working — you’re ready to write real SQL against real data.