473,569 Members | 2,634 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:\\t emp\\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 1582
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*******@gmai l.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
1570
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 while writing some test code. Opening and closing the file before invoking anydbm.open() was an attempt to delete the results of a previous test....
1
2675
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: exceptions.ImportError, no dbm clone found; tryed Is there a way to use the anydbm module anyway? thanks in advance
1
1910
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 length. The keys are likewise of varying length. Is anydbm the way to go? Is shelve anything more than a wrapper for it? Should I be looking at...
10
6946
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 I've thought of is to transform the dictionary in a
0
1186
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 opening your anydbm database to bias the preference towards gdbm instead of dbhash: # bias DBM towards gdbm if at all possible. def bias_anydbm():...
125
7116
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
10738
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 future Python versions and let dict.keys() and dict.values() both return sets instead of lists. If d is a dict, code like: for x in d.keys():
14
3444
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 list? I know that sets were introduced a lot later and lists/dictionaries were used instead but I think "the only correct way" now is for the...
0
1122
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 values? my_db.sync() didn't help -- apparently, it only *writes* to the DB file but doesn't read new data from it. Tschö, Torsten.
0
7701
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7615
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7677
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7979
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
940
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.