473,508 Members | 2,441 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
6 1577
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
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
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
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
*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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1567
by: Gary Richardson | last post by:
According to the Python Library Reference invoking anydbm.open() with flag value 'n' should always create a new empty database. However, the following code produces an error. I stumbled upon this...
1
2673
by: Alessandro Crugnola *sephiroth* | last post by:
Hi all I'm trying to compile a python app with py2exe (not the 0.5.0.. i think 0.4.1) which uses the anydbm module But when i launch the exe file created it raise this error:...
1
1903
by: Anton Sherwood | last post by:
Rather newbie question here. My current project will build a database of solutions to a topology problem, which I'll eventually put (readonly) on my website. The entries are text of varying...
10
6939
by: Luis P. Mendes | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, my program builds a dictionary that I would like to save in a file. My question is what are the simple ways to do it? The first solution...
0
1179
by: Eric S. Johansson | last post by:
I have a preference for gdbm when building DBM based dictionaries but have found I cannot count on it being there all the time. Therefore, I have created this little tidbit which you call before...
125
7070
by: Raymond Hettinger | last post by:
I would like to get everyone's thoughts on two new dictionary methods: def count(self, value, qty=1): try: self += qty except KeyError: self = qty def appendlist(self, key, *values): try:
90
10699
by: Christoph Zwerschke | last post by:
Ok, the answer is easy: For historical reasons - built-in sets exist only since Python 2.4. Anyway, I was thinking about whether it would be possible and desirable to change the old behavior in...
14
3437
by: vatamane | last post by:
This has been bothering me for a while. Just want to find out if it just me or perhaps others have thought of this too: Why shouldn't the keyset of a dictionary be represented as a set instead of a...
0
1119
by: Torsten Bronger | last post by:
Hallöchen! A TurboGears process opens a DB file with anydbm and keeps it open. The the same time, this file is updated by another process. How can I tell the TurboGears process to fetch the new...
0
7114
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7034
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5045
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.