[Tutor] Shelve Help!

Doug Stanfield DOUGS@oceanic.com
Fri, 18 Aug 2000 08:18:51 -1000


> Dear all,
>     I have the following error traceback from this line of code:
> 	code:	db = shelve.open('DataBase', 'w')

First, I don't think you want the 'w' as part of the open.  As far as I know
shelves are opened read/write with no additional parameter accepted.

-------------snip---------
> 		File "/usr/local/lib/python1.6/anydbm.py", line 
> 83, in open
> 		    raise error, "db type could not be determined"
> 		anydbm.error: db type could not be determined
> 
> I am afraid I have no idea why I am getting this error, the 
> DataBase file
> exists in the same directory as the program is ran from.

Usually when this happens to me it means I didn't close the shelve correctly
the last time I used it.  On the other hand it could be related to the above
inclusion of a 'w'.

I've never found a way to recover a shelve if it is corrupted like this.
Its one of my frustrations with shelves.  On the other hand, if you get your
program fully debugged it never seems to happen.  One of the ways to work
through the debug process might be to make a backup of the shelve every time
you get ready to open it.  That way, if it doesn't get closed you have
something to revert to.

> Any help as always is appreciated.
> Thank you,

Hope this wasn't off base.

-Doug-

> Kate
>