By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,172 Members | 762 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,172 IT Pros & Developers. It's quick & easy.

difference b/t dictionary{} and anydbm - they seem the same

P: n/a
anydbm and dictionary{} seem like they both have a single key and key
value.
Can't you put more information into a DBM file or link tables? I just
don't see the benefit except for the persistent storage.

d= dbm.open('c:\\temp\\mydb.dat','n')

It has the following interface (key and data are strings):

d[key] = data # store data at key (may override data at
# existing key)
data = d[key] # retrieve data at key (raise KeyError if no
# such key)
del d[key] # delete data stored at key (raises KeyError
# if no such key)
flag = key in d # true if the key exists
list = d.keys() # return a list of all existing keys (slow!)
Mar 11 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Tue, 2008-03-11 at 06:49 -0700, davidj411 wrote:
anydbm and dictionary{} seem like they both have a single key and key
value.
Can't you put more information into a DBM file or link tables? I just
don't see the benefit except for the persistent storage.
Persistent storage /is/ the benefit. If you want to store relational
data, you should use a relational database.

--
Carsten Haese
http://informixdb.sourceforge.net
Mar 11 '08 #2

P: n/a
davidj411 wrote:
anydbm and dictionary{} seem like they both have a single key and key
value.
Can't you put more information into a DBM file or link tables? I just
don't see the benefit except for the persistent storage.
Except for the persistent storage, that insignificant feature... ;) Well
I guess that persistent storage must be the reason some people use
anydbm sometimes.

If you want keys and values of any type (not just strings) and
persistent storage, you can use builtin dicts then pickle them.

Cheers,
RB

Mar 11 '08 #3

P: n/a
Persistent storage /is/ the benefit. If you want to store relational
data, you should use a relational database.
Thanks, that makes sense. Are there any local relational databases
available to python that don't require a server backend?
Mar 11 '08 #4

P: n/a
On Tue, Mar 11, 2008 at 10:58 AM, davidj411 <da*******@gmail.comwrote:
Thanks, that makes sense. Are there any local relational databases
available to python that don't require a server backend?
sqlite
http://www.sqlite.org/
Mar 11 '08 #5

P: n/a
*Thanks, that makes sense. Are there any local relational databases
*available to python that don't require a server backend?

sqlite
http://www.sqlite.org/
Are there any that aren't persistent?
Mar 11 '08 #6

P: n/a
Are there any that aren't persistent?
>
* * * * SQLite -- when opening a "memory" database rather than giving it a
physical file. {I'm a tad too busy to look up the format of the memory
parameter, but it shouldn't be too difficult to find it}
What? If I wanted to code string literals, I'd use exec. Where's the
real one?
Mar 12 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.