BSDDB problem

M.J.Fisher m.j.fisher at ex.ac.uk
Thu Jan 11 11:35:18 EST 2001


Hi,

I am using Python 2.0 on a Linux machine. I wanted to use the bsddb
module to get the information out the Netscape History.dat file. I tried
the following:

import bsddb
hist = bsddb.hashopen('history.dat', 'r')

I got the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
bsddb.error: (22, 'Invalid argument')

I have tried creating my own file using bsddb by copying the example
shown in the Python library.

s = bsddb.hashopen('spam.db', 'c')
...
s.close()

And then reading from this file and that works.

I used the 'file' command to compare the file types of the 'spam.db'
that I created and the 'history.dat' file. The 'history.dat' file had
the result:

history.dat: Berkeley DB Hash file (Version 2, Little Endian, Bucket
Size 4096,
Bucket Shift 12, Directory Size 256, Segment Size 256, Segment Shift 8,
Overflow Point 7, Last Freed 1, Max Bucket 122, High Mask 0x7f, Low Mask
0x3f, Fill Factor 57, Number of Keys 1666)

Whereas spam.db got the result:
spam.db : data

I am not sure whether this gives the clue to my problem. I tried using
the 'whichdb' module to determine the module I should use to open both
of these files.

whichdb.whichdb('history.dat')
whichdb.whichdb('spam.db')

and both resulted in the answer 'dbhash'

So I tried using the dbhash module to open history.dat and I got the
same error when I tried to use 'bsddb'.

h = dbhash.open('/home/sheerkahn3/mjfisher/.netscape/history.dat', 'r')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/sheerkahn3/mjfisher/Python-2.0/Lib/dbhash.py", line 8, in
open
    return bsddb.hashopen(file, flag, mode)
bsddb.error: (22, 'Invalid argument')

Sorry to make this so long winded!!! Thank you in advance for any
suggestions!!!!

Shelley




More information about the Python-list mailing list