Locate the position of an object in the specified index.
Cursor.search(cls, idx, op, value)
cls | The class to be searched |
idx | The index name used for the search |
op |
The compare operation to perform; one of the following (some are relevant only for RTree or Patricia indexes): |
value | The value to look up (if the index is a compound index, all of the values for the index components are passed as a tuple ) |
This method locates the position of an object in the specified index idx
applying the operation op
with key value
. It returns an object instance or None
if not found.
Object | An object of the specified class (if search is successful) |
None | No object found corresponding to the specified value |
# # Search operation # conn.startTransaction(exdb.Transaction.MCO_READ_ONLY) cursor = conn.cursor() ret = cursor.search("Record", "by_i4", exdb.Operation.GreaterOrEquals, 2) if ret: rec = cursor.next() print "Object found: i4=%s,str=%s" % (rec.i4, rec.str) rec = cursor.next() print "Next object is: i4=%s,str=%s" % (rec.i4, rec.str) else: print "Object not found" print "" cursor.close() conn.commit()