[egenix-users] BeeDict setting keys/comparison to shelve
M.-A. Lemburg
mal at lemburg.com
Thu Aug 8 22:26:18 CEST 2002
John.N.1 at bwc.state.oh.us wrote:
> Does anyone have comments on using Bdict instead of a standard shelf or
> bsddb ver3?
>
> Also, on Win2k, for me to change a dictionary element w/Bdict, I need to
> first delete the key and then set it's value.
> Should that be the case?
>
> When I run:
>
> d = mx.BeeBase.BeeDict.BeeDict('c:/tmp/test-BeeDict2')
> print 'original',d['Marc9']
> d['Marc9']='betty1'
> d.commit()
> print 'dict change\t',d.changed(),d['Marc9']
>
> del(d['Marc9'])
> d.commit()
> d['Marc9']='betty2'
> print 'del dict change\t',d.changed(),d['Marc9']
> d.close()
>
>
> produces:
>
> original Sveta
> dict change 0 Sveta
> del dict change 1 betty2
FYI, with egenix-mx-base 2.1.0b4 I get:
import mx.BeeBase.BeeDict
def test():
d = mx.BeeBase.BeeDict.BeeDict('testjohn.dat')
d['Marc9']='Sveta'
d.commit()
d.close()
d = mx.BeeBase.BeeDict.BeeDict('testjohn.dat')
print 'original',d['Marc9']
d['Marc9']='betty1'
d.commit()
print 'dict change\t',d.changed(),d['Marc9']
del(d['Marc9'])
d.commit()
d['Marc9']='betty2'
print 'del dict change\t',d.changed(),d['Marc9']
d.close()
test()
...
original Sveta
dict change 0 betty1
del dict change 1 betty2
Note that the 0 on the first change line indicates that
there are no changes in the cache (because you have called
.commit() on the line before). The second change line
still has the change in the cache, so 1 is returned and
the .close() will roll back the transaction.
HTH,
--
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting: http://www.egenix.com/
Python Software: http://www.egenix.com/files/python/
More information about the egenix-users
mailing list