By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,427 Members | 1,379 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,427 IT Pros & Developers. It's quick & easy.

bsddb : python, index, cursor and get

P: n/a
Hello,

I'm having problems to use the get method on a cursor with an index
(secondary database). I've read Oracle's docs but there are mainly in C,
JAVA and C++. So no python docs!

actually, that's what I'm trying to do :

ret = cursor.get(key='blabla', data='2007-10-30', flags=0, dlen=-1,
doff=-1)

this does not work.
the code above this line is :

########################### snip
def getDate(priKey, priData):
date = string.split(priData, ' ')[1]
return date

TheDB = db.DB()
TheDB.open(filename_pri, None, db.DB_BTREE, db.DB_RDONLY)

TheIDX = db.DB()
TheIDX.open(filename_idx2, None, db.DB_BTREE, db.DB_RDONLY)

TheDB.associate(TheIDX, getDate)
# get database cursor and print out database content
cursor = TheIDX.cursor()
########################### snip

Does anybody have some sample code which performs a lookup in a database
with an index using a cursor in Python?

Thanks a lot
Nov 13 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.