How do I read Berkeley DB files with Python?
I have this file ...
[root@dhcp-idev1 ndb]# file dhcp.ndb
dhcp.ndb: Berkeley DB (Btree, version 9, native byte-order)
... so I figure I can do this ...
[root@dhcp-idev1 ndb]# python2.3
Python 2.3.4 (#1, Jul 16 2009, 07:01:37)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import anydbm
>>> anydbm.open( './dhcp.ndb' )
... but I get this error message ...
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/anydbm.py", line 80, in open
raise error, "db type could not be determined"
anydbm.error: db type could not be determined
>>>
... what am I doing wrong?
dbm.open,gdbm.openordbhash.opendirectly? Also, thedbmbackend adds a.dbextension to the given file name, so try to rename your file todhcp.dband open it withdbm.open('dhcp').