Create a cursor for retrieving data on this connection.
Connection.cursor() or Connection.cursor(cls, idx)
This method has 2 different usage variants:
1) Calling
cursor()
without arguments creates a DB-API style cursor usable for operations likefind()
,search()
,execute()
,execute_many()
, etc.2) If a class
cls
and indexidx
are specified, it creates an “iteration” cursor, which will iterate over all objects of the specified class using the specified index. If an index is not provided, anautoid
orlist
index will be used. If noautoid
orlist
are defined for this class, an error will be thrown. The class and index may be specified as strings as declared in the schema, or passed as objects taken from the database dictionary. For example, the following two calls are equivalent:
>>>c = conn.cursor(‘myclass’, ‘idx’) >>>c = conn.cursor(dict.classes[‘myclass’],dict.indexes[’idx’])
cursor | The cursor object was instantiated successfully |
Exception | An exception is thrown with the appropriate error message |
conn = db.connect() conn.startTransaction(exdb.Transaction.MCO_READ_ONLY) cursor = conn.cursor("Record", "by_i4"); for rec in cursor: print 'i4=%s,str="%s"' % (rec.i4, rec.str) cursor.close(); # close cursor conn.rollback(); # end transaction