DuckDB: “Trying to read a database file with version number…”

The file is not damaged. It was written by a DuckDB that stores data differently from the one reading it. The two numbers in the error tell you which side is out of date, and that decides the fix.

Read the two numbers

A file that is too old for the DuckDB reading it:

IO Error: Trying to read a database file with version number 51,
but we can only read versions between 64 and 68.
The database file was created with DuckDB version v0.8.0 or v0.8.1.

A file that is too new:

IO Error: Trying to read a database file with version number 68,
but we can only read versions between 64 and 66.
The database file was created with an newer version of DuckDB.

If the file's number is below the range, the file is older than your DuckDB can handle. If it is above, the file is newer. A DuckDB from before 1.0 says the same thing less helpfully:

Serialization Error: Failed to deserialize: expected end of object,
but found field id: 101

That one means the file is too new for it.

What opens where

To see which format a file uses, if you can open it:

duckdb -readonly mydata.duckdb -c "SELECT database_name, tags FROM duckdb_databases()"

The storage_version tag is the oldest DuckDB that can read it. duckdb --version tells you what you are running.

The file is too new

Upgrade the DuckDB reading it. That is brew upgrade duckdb for the command line, or pip install -U duckdb for Python.

If you cannot upgrade, ask whoever made the file to rewrite it in the default format. With a current DuckDB:

ATTACH 'mydata.duckdb' AS src (READ_ONLY);
ATTACH 'mydata-compat.duckdb' AS dst (STORAGE_VERSION 'v1.0.0');
COPY FROM DATABASE src TO dst;

Or ask for the tables as Parquet, which every version reads.

The file is too old

A file from before DuckDB 0.9 has to be opened by an old DuckDB, exported, and imported into a new one. The error names the version that made it. With uv installed, you can borrow that version without installing it:

uvx -p 3.11 --with duckdb==0.8.1 python -c \
  "import duckdb; duckdb.connect('old.duckdb', read_only=True).execute(\"EXPORT DATABASE 'old-export'\")"

duckdb new.duckdb -c "IMPORT DATABASE 'old-export'"

The export is a folder of plain files and a script that recreates the schema, so nothing is lost along the way. Python 3.11 is there because DuckDB releases that old have no packages for newer Pythons.

In Datapuddle

Datapuddle has DuckDB 1.5.5 compiled in, which reads versions 64 to 68: every file from DuckDB 0.9 onwards, including ones written in the 1.5 format. A file from before 0.9 needs the export above first. A file written by a DuckDB newer than 1.5.5 in a newer format will open once the app is updated.

Download on the Mac App Store 7-day trial, then $39.99 once · Apple silicon, macOS 26 or later

Questions

Is my DuckDB file corrupted?

Almost certainly not. A version number error means the file was written by a different DuckDB release. Your data is intact; it needs a matching reader, or converting.

Can an older DuckDB open a file from a newer one?

Usually, yes. By default DuckDB 1.5 writes files that DuckDB 1.0 and later can read. Only files written with a newer STORAGE_VERSION on purpose need a newer reader.

Can DuckDB 1.x open a database from 0.8 or earlier?

No. Open it with the old version, run EXPORT DATABASE, and run IMPORT DATABASE in the new one.

How do I check which DuckDB version I have?

duckdb --version on the command line, or SELECT version() from any DuckDB client.

Datapuddle on the Mac App Store — 7 day trial, then $39.99 once. Apple silicon, macOS 26 or later. · Docs Guides · Home