Find a database object by an index key value.
Cursor.find(cls, idx, value)
cls | The class to be searched |
idx | The index name used for the search |
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 finds an object in the database using the specified index idx
and 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 |
conn = db.connect() conn.startTransaction(exdb.Transaction.MCO_READ_WRITE) # Perform simple index search: locate Record by id cursor = conn.cursor() # find record to update rec = cursor.find("Record", "by_i4", 2) # update object rec.str = "Updated string" cursor.close() #release cursor conn.commit() # commit changes