dbhash on win and on cygwin not compatible ?

Jason Tishler jason at tishler.net
Wed May 14 15:33:43 EDT 2003


Rony,

Note that I am *very* inexperienced with DBM, Berkeley DB library,
etc.  So, anyone with experience in this area, please jump in...

On Wed, May 14, 2003 at 10:32:15AM -0700, Rony wrote:
> ActivePython 2.2.2 Build 224 (ActiveState Corp.) based on
> Is there a difference between the two that causes my problem ?

It seems like it...

> Same python version for both
> 
> Python 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import dbhash
> >>> dbhash.open('reception.db')
> <bsddb.bsddb object at 0x0087BE08>

What kind of database is reception.db?  Is it Hash or Btree?  What
version?  What created reception.db?  What kind of database does
ActivePython create when dbhash.open('foo.db', 'c') is invoked?

> Python 2.2.2 (#1, Mar  9 2003, 08:18:26)
> [GCC 3.2 20020927 (prerelease)] on cygwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import dbhash
> >>> dbhash.open('reception.db')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/usr/lib/python2.2/dbhash.py", line 16, in open
>     return bsddb.hashopen(file, flag, mode)
> bsddb.error: (22, 'Invalid argument')

I think the above is failing because Cygwin Python is expecting a Hash,
version 7 Berkeley DB file:

    $ file *.db
    foo.db:  Berkeley DB (Btree, version 8, native byte-order)
    foo2.db: Berkeley DB (Hash, version 7, native byte-order)

    $ python
    Python 2.2.2 (#1, Mar  9 2003, 08:18:26) 
    [GCC 3.2 20020927 (prerelease)] on cygwin
    Type "help", "copyright", "credits" or "license" for more information.

    >>> import dbhash    
    >>> dbhash.open('foo.db')
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File "/usr/lib/python2.2/dbhash.py", line 16, in open
        return bsddb.hashopen(file, flag, mode)
    bsddb.error: (22, 'Invalid argument')

    >>> dbhash.open('foo2.db')
    <bsddb.bsddb object at 0xa0ab4d0>

The above demonstrates that Cygwin Python seems to be only able to open
a Hash, version 7 Berkeley DB via dbhash.open().

Additionally, note the following:

    >>> import bsddb
    >>> bsddb.btopen('foo.db')
    <bsddb.bsddb object at 0xa0b2008>

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

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

    >>> bsddb.hashopen('foo2.db')
    <bsddb.bsddb object at 0xa0be180>

The above demonstrates that Cygwin Python can successfully open a Btree,
version 8 Berkeley DB via bsddb.btopen().

> Thanks for an hints to solve this problem.

What happens if you open reception.db with bsddb.btopen()?  Does it
work?  Unfortunately, even if works, I don't know how to solve your
problem without changing your code.

Jason

-- 
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6





More information about the Python-list mailing list