سؤال

I'm trying to read the database files created by reprepro. I don't have that much experience with bdb, so I might be confused here, but it looks like the database is layered in some way.

If I simply do btopen('path/to/packages.db', 'r'), I get the database object with contents like:

In [4]: packages.items()
Out[4]: 
[('local-lenny|main|amd64', '\x00\x00\x00\x04'),
 ('local-lenny|main|i386', '\x00\x00\x00\x02'),
 ('local-lenny|main|powerpc', '\x00\x00\x00\x14'),
 ('local-lenny|main|source', '\x00\x00\x00\x06'),
 ('local-lenny|main|sparc', '\x00\x00\x00\x12')]

However the db4.6_dump shows:

VERSION=3
format=bytevalue
database=local-lenny|main|sparc
type=btree
db_pagesize=4096
HEADER=END
 <loads of data>

The file itself is identified as: /var/packages/db/packages.db: Berkeley DB (Btree, version 9, native byte-order) by file.

How do I get to that contents? If I understand it correctly, I got only the names of actual databases in keys(). How do I get to the contents of those dbs now?

هل كانت مفيدة؟

المحلول

And the answer seems to be that the "nice" version of the bsddb interface doesn't support multi btree tables inside one file. You can open such table explicitly via bsddb.db, using:

env = db.DBEnv()
env.open(None, db.DB_CREATE | db.DB_INIT_MPOOL)
internal_db = db.DB(env)
internal_db.open("the filename", "the internal db name", db.DB_BTREE, db.DB_RDONLY)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top