bsddb : python, index, cursor and get

P

Pierre

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top