PythonWin 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on
win32.
Portions Copyright 1994-2001 Mark Hammond (mhammond@skipp inet.com.au) - see
'Help/About PythonWin' for further copyright information.[color=blue][color=green][color=darkred]
>>> import os
>>> import bsddb
>>> os.chdir("c:/test")
>>> my_data = bsddb.btopen("t esting", 'c')
>>> for i in range(10):[/color][/color][/color]
.... if i == 5:
.... pass
.... else:
.... my_data['%d'%i] = '%d'% (i*i)
....[color=blue][color=green][color=darkred]
>>> my_data.keys()[/color][/color][/color]
['0', '1', '2', '3', '4', '6', '7', '8', '9'][color=blue][color=green][color=darkred]
>>> my_data.sync()[/color][/color][/color]
Now heres where my problem is.
The documentation explicitly states that a btopen database when asked to
locate a key that doesn't exist in the dataset, will return the next sorted
key from the dataset.
So my_data.set_loc ation('5') should return as if I'd called
my_data.set_loc ation('6')[color=blue][color=green][color=darkred]
>>> my_data.set_loc ation('5')[/color][/color][/color]
Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
File "C:\Python23\li b\bsddb\__init_ _.py", line 117, in set_location
return self.dbc.set(ke y)
DBNotFoundError : (-30991, 'DB_NOTFOUND: No matching key/data pair found')
Okay maybe it has positioned the cursor, but is just raising the exception
to politely tell me that I'm not pointing at the key I asked for. So
my_data.previou s() will return the key/data pair for key "4".
[color=blue][color=green][color=darkred]
>>> my_data.previou s()[/color][/color][/color]
('9', '81')
Okay its pointing at the end of the database. Erm thats not as advertised.
Okay whats broken? Is the documentation wrong? Is my version of Python
wrong?, or do I need to drink some more coffee?
TonyM
win32.
Portions Copyright 1994-2001 Mark Hammond (mhammond@skipp inet.com.au) - see
'Help/About PythonWin' for further copyright information.[color=blue][color=green][color=darkred]
>>> import os
>>> import bsddb
>>> os.chdir("c:/test")
>>> my_data = bsddb.btopen("t esting", 'c')
>>> for i in range(10):[/color][/color][/color]
.... if i == 5:
.... pass
.... else:
.... my_data['%d'%i] = '%d'% (i*i)
....[color=blue][color=green][color=darkred]
>>> my_data.keys()[/color][/color][/color]
['0', '1', '2', '3', '4', '6', '7', '8', '9'][color=blue][color=green][color=darkred]
>>> my_data.sync()[/color][/color][/color]
Now heres where my problem is.
The documentation explicitly states that a btopen database when asked to
locate a key that doesn't exist in the dataset, will return the next sorted
key from the dataset.
So my_data.set_loc ation('5') should return as if I'd called
my_data.set_loc ation('6')[color=blue][color=green][color=darkred]
>>> my_data.set_loc ation('5')[/color][/color][/color]
Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
File "C:\Python23\li b\bsddb\__init_ _.py", line 117, in set_location
return self.dbc.set(ke y)
DBNotFoundError : (-30991, 'DB_NOTFOUND: No matching key/data pair found')
Okay maybe it has positioned the cursor, but is just raising the exception
to politely tell me that I'm not pointing at the key I asked for. So
my_data.previou s() will return the key/data pair for key "4".
[color=blue][color=green][color=darkred]
>>> my_data.previou s()[/color][/color][/color]
('9', '81')
Okay its pointing at the end of the database. Erm thats not as advertised.
Okay whats broken? Is the documentation wrong? Is my version of Python
wrong?, or do I need to drink some more coffee?
TonyM