Very Stupid Newbie Question Regarding Databases

Sposhua sposhua at my.pc
Mon Dec 20 10:21:19 EST 1999


On Sun, 19 Dec 1999 55wgm_guy at my-deja.com wrote:

> Okay, Im obviously new to the Python world, but I have a project Im
> working on that will require databases. In particular, I want to store
> multiple records in the format:
> 
> Name:
> Email:
> Phone Number:
> (etc)
> 
> Im starting to look at the gdbm, dbm, and anydbm modules. However, it
> seems to me that to store records in the above format would require
> some sort of key to retrieve a particular record.  How can the *dbm
> modules do this?

I'd use shelve. Then all you do is create a dictionary like

d = {"Eric Idle":["eric at monty.com","(01)5678",...],"John
Cleese":[john at circus.com","(01)2345",...]...}

and save to a dbm file using shelve.





More information about the Python-list mailing list