471,595 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,595 software developers and data experts.

GDBM incompatibility in different python versions?

I have been trying to get the gdbm module in python 2.4 to read a gdbm file from python 1.5.2 and having no luck. I get a file error when I try to open the 1.5.2-created gdbm file.

Even a very simple gdbm database causes the trouble. E.g. I create a one-entry db in python 1.5.2
Expand|Select|Wrap|Line Numbers
  1. Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
  2. Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
  3. >>> import gdbm
  4. >>> db2 = gdbm.open(r'C:\test.gdbm','n')
  5. >>> db2['key1']='spiffweed'
  6. >>> db2.close()
Then when I try to open the file in python 2.4
Expand|Select|Wrap|Line Numbers
  1. Python 2.4 (#1, Dec  4 2004, 20:10:33)
  2. [GCC 3.3.3 (cygwin special)] on cygwin
  3. Type "help", "copyright", "credits" or "license" for more information.
  4. >>> import gdbm
  5. >>> db = gdbm.open(r"c:\test.gdbm","r")
  6. Traceback (most recent call last):
  7.   File "<stdin>", line 1, in ?
  8. gdbm.error: File read error
So, I am stuck. Is there some way to tell which version of GDBM is being used in python 1.5.2? The versions I have been playing with in 2.4 are GDBM 1.7.2 and 1.8.3.

BTW, I have to be able to read the gdbm files created in python 1.5.2 in a more recent version of python - I have no choice in that. Doing everything in the same python is not an option here.

[If this belongs in the DB section of the board, please feel free to move it. I have only played with gdbm files in python, and I don't see an area for gdbm specifically, so I posted here.]
Mar 26 '07 #1
1 1672
BTW, I could provide the gdbm file I get when using python 1.5.2 if it would help. It's only 3085 bytes.

It occurs to me that there may have been some other difference that is causing my incompatibility besides just the gdbm version (like the gdbm module having been compiled to use null-terminated strings or some such, though I don't think that is the issue here).

The gdbm file I get under python 1.5.2's gdbm is here as test.gdbm. (And, for reference, the one I get when I create one using the same code in newer pythons is here as test2.gdbm .)
Mar 26 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.