about bsddb module

cocobear cocobear.cn at gmail.com
Sat May 3 07:17:36 EDT 2008


How to deal with multiple databases in an file. I want to get the
content of several databases.

it's the code I wrote:

[cocobear at cocobear ~]$ python
Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11)
[GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bsddb
>>> import os
>>> import time
>>>
>>> db_file = 'native.db'
>>> db = bsddb.db.DB()
>>> db.open(db_file,bsddb.db.DB_UNKNOWN,bsddb.db.DB_RDONLY)
>>> dbs = db.keys()
>>> db.open(db_file,dbs[0],bsddb.db.DB_UNKNOWN,bsddb.db.DB_RDONLY)
>>> db.keys()
['\x01\x00\x00\x00', '\x02\x00\x00\x00', '\x03\x00\x00\x00',
'\x04\x00\x00\x00', '\x05\x00\x00\x00']
>>> db.open(db_file,dbs[1],bsddb.db.DB_UNKNOWN,bsddb.db.DB_RDONLY)


the program stop here.



More information about the Python-list mailing list