471,312 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

bsddb : python, index, cursor and get

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
0 1003

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Anthony McDonald | last post: by
3 posts views Thread by Harry Pehkonen | last post: by
1 post views Thread by Mike Moum | last post: by
reply views Thread by Jane Austine | last post: by
4 posts views Thread by Michele Simionato | last post: by
reply views Thread by Barry | last post: by
1 post views Thread by BjornT | last post: by
1 post views Thread by partofthething | last post: by

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.