Cursor.find

Find a database object by an index key value.

For an overview see page Python Cursor Class

Prototype

 
    Cursor.find(cls, idx, value)
 

Arguments

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)

Description

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.

Returns

Object An object of the specified class (if search is successful)
None No object found corresponding to the specified value

Example

     
    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