DuckDB connection string builder
DuckDB runs inside your process and opens a file, so its "connection string" is a path. Build the JDBC URL, Python call, SQLAlchemy URL and CLI command for a database file, read-only or in-memory. It all runs in your browser: nothing you type is sent anywhere.
Open this connection in SQLly
Opens SQLly's connection editor filled in.
Open this connection in SQLly
Private by design. The builder and decoder are plain JavaScript running in this tab. The page sends no request with what you type, stores nothing (not even in your browser), and keeps working offline once loaded. The Open in SQLly link goes from your browser straight to the app on your computer.
DuckDB connection string formats
Every DuckDB client opens a database file path, or :memory: for a temporary in-memory database. Only one process can open a file read-write at a time; several processes can share it read-only.
File path every client, SQLly
/var/data/analytics.duckdb
JDBC DuckDB JDBC driver
jdbc:duckdb:/var/data/analytics.duckdb
SQLAlchemy URL duckdb-engine
duckdb:////var/data/analytics.duckdb
CLI, read-only duckdb
duckdb -readonly /var/data/analytics.duckdb
Placeholders such as your_password are just that: build your own string with the form above. More about connecting SQLly to DuckDB: SQLly for DuckDB.
Opening a DuckDB database
Read-only mode lets several processes read one file.
| Keyword | Synonyms | Default | What it does |
|---|---|---|---|
JDBC |
- | jdbc:duckdb: (in-memory) | jdbc:duckdb:/path/file.duckdb; read-only with the duckdb.read_only=true connection property. Settings can follow with semicolons: jdbc:duckdb:/path;threads=4. |
Python |
- | :memory: | duckdb.connect("file.duckdb", read_only=True). |
SQLAlchemy |
- | - | duckdb:///relative.duckdb, duckdb:////abs/path.duckdb, duckdb:///:memory:; read-only via connect_args={"read_only": True}. |
CLI |
- | in-memory | duckdb file.duckdb; add -readonly for read-only. |
Node.js |
- | - | @duckdb/node-api: await DuckDBInstance.create("file.duckdb"). |
Common DuckDB connection errors
IO Error: Could not set lock on file "analytics.duckdb": Conflicting lock is held
Why: Another process already has the file open read-write (often a notebook, a CLI session or a second app instance).
Fix: Close the other process, or open both read-only if neither needs to write.
IO Error: Cannot open database "analytics.duckdb" in read-only mode: database does not exist
Why: Read-only mode never creates the file, and the path is wrong or relative to an unexpected working directory.
Fix: Use an absolute path to an existing database.
DuckDB connection string FAQ
Does DuckDB have a connection string?
Not in the client/server sense: DuckDB is embedded, so you open a file path (or :memory:). The wrappers differ: jdbc:duckdb:/path in Java, duckdb:///path in SQLAlchemy, a plain path in Python, Node and the CLI.
How do I open a DuckDB file read-only?
read_only=True in Python, the duckdb.read_only=true property in JDBC, connect_args={"read_only": True} in SQLAlchemy, or duckdb -readonly file.duckdb in the CLI.
Can two programs use the same DuckDB file?
Only one process may hold it read-write. Several processes can open it read-only at the same time.
Other engines
Connect once. Then just write SQL.
SQLly is a native SQL workbench for macOS, Windows and Linux. Paste a connection string into its connection editor, keep passwords in your system keychain, and get schema-aware IntelliSense on DuckDB and more.