1

I have been using duckdb and have a database but recently I updated duckdb and not able to use the duckdb and getting following error.

duckdb.IOException: IO Error: Trying to read a database file with version number 39, but we can only read version 43. The database file was created with DuckDB version v0.6.0 or v0.6.1.

The storage of DuckDB is not yet stable; newer versions of DuckDB cannot read old database files and vice versa. The storage will be stabilized when version 1.0 releases.

For now, we recommend that you load the database file in a supported version of DuckDB, and use the EXPORT DATABASE command followed by IMPORT DATABASE on the current version of DuckDB.

See the storage page for more information: https://duckdb.org/internals/storage

Although I have tried to IMport and Export I am not able to find right syntax for the same using python

Arun Kumar
  • 13
  • 4

1 Answers1

2

Duckdb new versions are currently not backward compatible.

You must use EXPORT database using old version of duckdb and then IMPORT database using new version of duckdb

To start, you can use pip to install the specific version of DuckDB that matches the version used to create the database you want to export. For example, if the database was created using version 0.6.0 of DuckDB, you can install that version with the command:pip install duckdb==0.6.0

Next, you can connect to the database you want to export using Python and execute the EXPORT DATABASE command to save the database to a directory:

import duckdb
conn = duck.connect('<databasefilename>')
conn.execute("EXPORT DATABASE '<directory to save exported database>")

Once you have exported all the required databases, you can upgrade to the latest version of DuckDB with the command:pip install --upgrade duckdb

Finally, you can create a new database file with the new version of DuckDB and import the exported databases with the command:

import duckdb
conn=duckdb.connect('<newdbfilename>')
conn.execute("IMPORT DATABASE '<directory where exported database was saved>'")

With these instructions, you should be able to upgrade to a new version of DuckDB while still retaining access to your existing databases.