The Cursor class represents a cursor to iterate through instances of a specified class, the result set of a find/search operation, or the result set from SQL queries. It provides the following methods:
Find a database object of class cls by an index idx and key value (a DB API compliant call)Locate the position of a database object of class cls in an index idx and key value using the operation op (a DB API compliant call)checkpoint()Checkpoint the cursor; this updates the index for any updated objects previously returned by the methods first(), last(), next(), prev() or skip().close()Close the cursorgetAutoId()Get the autoid of the current objectfirst()Move cursor to the first positionlast()Move cursor to the last positionnext()Move cursor to the next positionprev()Move cursor to the previous positionskip()Move cursor to the next position without retrieving the elementreset()Reset (rewind) the cursorcurrent()Return the object to which the cursor is referringExecute a SQL query against the database substituting arguments args for format specifiers in the query string (a DB API compliant call)Execute a SQL query against the database applying a set of parameters args (a DB API compliant call)Return the next row of result set (a DB API compliant call)Fetch the next set of rows from a result set optionally specifying the size of the result set (a DB API compliant call)Fetch all (remaining) rows of a query result (a DB API compliant call)rowcountThe read-only property that indicates the number of rows affectedUsing a Cursor as a Context Manager
Starting with eXtremeDB version 8.4.1806, the
Cursortype supports the context manager protocol. This allows automatic cleanup of the cursor when exiting thewithblock, even if an error occurs.It is recommended to use the following pattern to ensure the cursor is properly closed:
with con.cursor("Record") as cursor: for rec in cursor: printRecord(rec)This approach guarantees that resources associated with the cursor are released reliably, without requiring an explicit
close()call.
- See also: Using Python with eXtremeDB