473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

bsddb.btopen()

PythonWin 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on
win32.
Portions Copyright 1994-2001 Mark Hammond (mh******@skippinet.com.au) - see
'Help/About PythonWin' for further copyright information.
import os
import bsddb
os.chdir("c:/test")
my_data = bsddb.btopen("testing", 'c')
for i in range(10): .... if i == 5:
.... pass
.... else:
.... my_data['%d'%i] = '%d'% (i*i)
.... my_data.keys() ['0', '1', '2', '3', '4', '6', '7', '8', '9'] my_data.sync()
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_location('5') should return as if I'd called
my_data.set_location('6') my_data.set_location('5') Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python23\lib\bsddb\__init__.py", line 117, in set_location
return self.dbc.set(key)
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.previous() will return the key/data pair for key "4".
my_data.previous()

('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
Jul 18 '05 #1
0 1581

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Harry Pehkonen | last post by:
Stats: Python2.3 windows2000 professional If I have ``Full Control'' of a bsddb file, no problem: >>> import bsddb >>> a = bsddb.btopen("c:/sharedrw/db/npanxx2pseudo.db", "r") >>> a.close()...
4
by: Michele Simionato | last post by:
I was browsing through the source tree of Python 2.4b2 and in Lib/bsddb/test I found a lot of interesting stuff. It seems that the support for the bsd database is much better than documented in the...
7
by: martijn | last post by:
WHen I use the code below and printing all the results i get this: ------ 0 1 10 11 2 3 4 5 6 7 8 9 ------ But I want ------ 0 1 2
0
by: Neville C. Dempsey | last post by:
#!/bin/env python import bsddb test=bsddb.btopen("test.tbl") for m in "JFMATQPHSOND": test="Profit for month "+m+" $1B" def subyear_report(record_selection): for data in...
0
by: Barry | last post by:
I have python2.4.1 installed on two machines: -- one is Fedora core 1, where the bsddb module works fine -- one is Redhat ES 3.0, and I installed mysql 4.1 (and mysql-python2.1) after putting the...
2
by: lazy | last post by:
Hi, I have a dictionary something like this, key1=>{key11=> , key12=> , .... } For lack of wording, I will call outer dictionary as dict1 and its value(inner dictionary) dict2 which is a...
1
by: BjornT | last post by:
Have a rather big problem with bsddb I can't figure out. I upgraded an Ubuntu machine from 7.05 to 7.10 which upgraded python to 2.5.1 I run a local website that uses bsddb, and suddenly I get a...
2
by: cocobear | last post by:
How to deal with multiple databases in an file. I want to get the content of several databases. it's the code I wrote: $ python Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11) on linux2...
0
by: sconnoll | last post by:
import bsddb bsddb.btopen(file, flag='c', mode=438, btflags=0, cachesize=None, maxkeypage=None, minkeypage=None, pgsize=None, lorder=None) Can anyone help me with the values to use for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.