[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

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

davidj411

3/11/2008 1:50:00 PM

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!)
7 Answers

Carsten Haese

3/11/2008 2:02:00 PM

0

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.sourc...


Robert Bossy

3/11/2008 2:11:00 PM

0

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

davidj411

3/11/2008 2:58:00 PM

0


> 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?

Joe Riopel

3/11/2008 3:05:00 PM

0

On Tue, Mar 11, 2008 at 10:58 AM, davidj411 <davidj411@gmail.com> wrote:
> Thanks, that makes sense. Are there any local relational databases
> available to python that don't require a server backend?

sqlite
http://www.s...

Aaron Brady

3/11/2008 9:56:00 PM

0

> >  Thanks, that makes sense. Are there any local relational databases
> >  available to python that don't require a server backend?
>
> sqlite
> http://www.s...

Are there any that aren't persistent?

Dennis Lee Bieber

3/12/2008 6:01:00 AM

0

On Tue, 11 Mar 2008 14:56:26 -0700 (PDT), castironpi@gmail.com declaimed
the following in comp.lang.python:

>
> 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}
--
Wulfraed Dennis Lee Bieber KD6MOG
wlfraed@ix.netcom.com wulfraed@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: web-asst@bestiaria.com)
HTTP://www.bestiaria.com/

Aaron Brady

3/12/2008 6:18:00 AM

0

> > 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?