Python – Problem opening berkeley db in python


I have problems opening a berkeley db in python using bdtables. As bdtables is used by the library I am using to access the database, I need it to work.

The problem seems to be that the db environment I am trying to open (I got a copy of the database to open), is version 4.4 while libdb is version 4.6. I get the following error using bsddb.dbtables.bsdTableDB([dbname],[folder]):

(-30972, "DB_VERSION_MISMATCH: Database environment version mismatch -- Program version 4.6 doesn't match environment version 4.4")

However, bsddb.btopen([dbname]) works.

I have also tried installing db4.4-util, db4.5-util and db4.6-util. Trying to use db4.6_verify results in:

db4.6_verify: Program version 4.6 doesn't match environment version 4.4
db4.6_verify: DB_ENV->open: DB_VERSION_MISMATCH: Database environment version mismatchs

db4.4_verify results in the computer just hanging, and nothing happening.

Finally, if I run db4.4_recover on the database, that works. However, afterwards I get the following error 'No such file or directory' in python.

Best Solution

I think answers should go in the "answer" section rather than as an addendum to the question since that marks the question as having an answer on the various question-list pages. I'll do that for you but, if you also get around to doing it, leave a comment on my answer so I can delete it.

Quoting "answer in question":

Verifying everything in this question, I eventually solved the problem. The 'No such file or directory' are caused by some __db.XXX files missing. Using

bsddb.dbtables.bsdTableDB([dbname],[folder], create=1)

after db4.4_recover, these files got created and everything is now working.

Still, it was a bit of an obscure problem, and initially hard to figure out. But thanks to the question Examining Berkeley DB files from the CLI, I got the tools I needed. I'll just post it here if someone ends up with the same problem in the future and end up at