Installing DuckDB: CLI, Python, Node.js, and First Connection

Install DuckDB across the CLI, Python, and Node.js, and make your first connection — in-memory or persisted to a database file.

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

Terminal window
# 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:

Terminal window
duckdb
D 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

Terminal window
pip install duckdb
import duckdb
# Query directly, no connection object needed for one-off queries
duckdb.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

Terminal window
npm install @duckdb/node-api
import { 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

ModeHowUse case
In-memoryduckdb.connect() / no filenameOne-off scripts, tests, ephemeral analysis
Persistent fileduckdb.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 works
LOAD 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.