How to open a .duckdb file
A .duckdb file is an entire database in a
single file — tables, views, indexes and all. Unlike a CSV there is
nothing to sniff and nothing to import; you attach to it and the catalog
is there.
The command line (free)
brew install duckdb
duckdb mydata.duckdb
D SHOW TABLES;
D SELECT * FROM orders LIMIT 20;
That is the whole thing. .tables and DESCRIBE get
you oriented, and it is genuinely all some people need.
If you would rather click than type, duckdb -ui mydata.duckdb
opens DuckDB's own interface in a browser tab on the same file. Your data
stays on your Mac, but the interface is loaded from DuckDB's servers, so it
needs a connection.
The catch nobody warns you about
DuckDB's storage format changes between releases. Most files still move
between versions without trouble, because new files are written in an old
format by default. But a file from before DuckDB 0.9, or one
deliberately written in a newer format, will not open in the wrong
release. If you are handed a .duckdb and it refuses
to open with an error about a version number, the usual cause is not
corruption. Whoever made it was on a different version than you.
The fix is to upgrade the reader, convert the file, or ask for it as Parquet, which has no such problem. This applies to every tool including this one: Datapuddle ships DuckDB 1.5.5 compiled in. The version error guide shows how to tell which side is out of date, and the fix for each.
It is worth knowing before you conclude the file is broken.
The other one: “Could not set lock on file”
IO Error: Could not set lock on file "mydata.duckdb":
Conflicting lock is held in /usr/bin/python3 (PID 4821)
Something else already has the database open. A .duckdb file
can have one writer, and while a program holds it for writing,
nothing else can open it, not even to read. The usual culprit is a
notebook kernel or a duckdb shell still running in another
terminal. The error names the program and its process ID.
Close that program and try again. If several programs need the file at
once, every one of them has to open it read-only, for example
duckdb -readonly mydata.duckdb. Any number of read-only readers
can share it.
Datapuddle follows the same rule. It opens a database for writing, and if that is refused it tries again read-only. While Datapuddle has a database open for writing, your scripts will get this error too, so close it there first.
More on finding the program that holds the lock, and what to do when two programs both need to write: “Could not set lock on file”.
Doing it in Datapuddle
- Double-click the file, or ⌘O.
- The catalog appears in the sidebar: every schema, table and view in the database.
- Click a table to see it, or write SQL against it in the editor.
Because it is DuckDB underneath, you can attach other things alongside and query across them — a Parquet file on your disk, an S3 bucket, a Postgres database — in a single statement, without moving anything.
Query plans render as a waterfall after ⌘⇧↩, which is the fast way to find out why something in an unfamiliar database is slow.
Which to use
- You know what you are looking for — the CLI.
- You are exploring someone else's database — a sidebar
with the catalog in it saves a lot of
SHOW TABLES. - The file will not open at all — check versions before anything else.
- It says the file is locked — find the other program that has it open, or open it read-only.
Questions
Can I open a .duckdb file in Excel?
Not directly. Excel and Numbers do not read DuckDB's format.
Export the table you want to a CSV and open that:
duckdb mydata.duckdb -c "COPY orders TO 'orders.csv'". If the
table is large, see opening a CSV
that is too big for Excel.
Is a .duckdb file the same as a SQLite database?
No. Both keep a whole database in one file, but the formats
are different, and SQLite tools cannot open a .duckdb file.
DuckDB can read SQLite files, though, so DuckDB tools open both.
My file ends in .db. Is it DuckDB or SQLite?
Look at its first bytes with xxd -l 16 mydata.db.
A SQLite file starts with SQLite format 3. A DuckDB file has
DUCK in bytes 8 to 11.
DuckDB does not care about the extension, so a DuckDB file
named .db opens fine from the command line. Datapuddle opens
files ending in .duckdb, so rename a copy.
Why won't my .duckdb file open?
Almost always one of two things. Either it was written by a newer DuckDB than the one reading it, or another program has it open. Real corruption is rare.
Can I open a .duckdb file without the command line?
Yes. A native app such as Datapuddle opens it with a double-click. DuckDB's own browser UI also avoids typing SQL into a terminal, but you start it from the command line.
Datapuddle on the Mac App Store — 7 day trial, then $39.99 once. Apple silicon, macOS 26 or later. · Docs Guides · Home