Lokoluka
Lokoluka

Reputation: 101

Retrieve ZODB database structure

I recently received a ZODB file (.fs) which contain a erp5 database. I need to retrieve the data stored but I don't know the database structure.

What I need is some lines of code (if possible) to gather the "tables" and the "records" stored in the DB.

This is how I get connected to the database.

from ZODB import FileStorage, DB

storage = FileStorage.FileStorage('D:\slappart88\srv\zodb\main.fs')

db = DB(storage)
conn = db.open()
root = conn.root()
fsi = storage.iterator()

print db
print conn
print root
print fsi

db.close()

Getting this output:

<ZODB.DB.DB object at 0x00000000028395C0>
<Connection at 02978128>
{'Application': <persistent broken OFS.Application.Application instance     '\x00\x00\x00\x00\x00\x00\x00\x01'>}
<ZODB.FileStorage.FileStorage.FileIterator object at 0x0000000002978198>

I'll appreciate any help.

Thank you!

Upvotes: 3

Views: 970

Answers (1)

larsks
larsks

Reputation: 312530

ZODB is an "object" storage file format. It doesn't really have "records" and "tables"; it does have a collection of pickled objects, and it's really meant to be used by the particular application that knows about those objects.

If your primary goal is just inspecting the contents of the ZODB, you can try eye, which gives you a browser-based interface to the database contents.

Looking at the code for eye may offer some ideas on how to extract information yourself, although there's an excellent chance you won't be able to get anything useful without using the originating application.

There's a longer discussion of this topic here.

Upvotes: 3

Related Questions