kexi
Kross::KexiDB::KexiDBCursor Class Reference
#include <kexidbcursor.h>
Inherits Kross::Api::Class< Kross::KexiDB::KexiDBCursor >.
Detailed Description
The cursor provides a control structure for the successive traversal of records in a result set as returned e.g.by a query.
Example (in Python) that shows how to iterate over the result of a query;
# Once we have a KexiDBConnection object we are able to execute a query string and get a cursor as result. cursor = connection.executeQueryString("SELECT * from emp") # Let's check if the query was successfully. if not cursor: raise("Query failed") # Walk through all items in the table. while(not cursor.eof()): # Iterate over the fields the record has. for i in range( cursor.fieldCount() ): # Print some information. print "%s %s %s" % (cursor.at(), i, cursor.value(i)) # and move on to the next record. cursor.moveNext()
Example (in Python) that shows how to use a cursor to strip all whitespaces at the beginning and the end from the values in a table;
import krosskexidb drivermanager = krosskexidb.DriverManager() connectiondata = drivermanager.createConnectionDataByFile("/home/me/kexiprojectfile.kexi") driver = drivermanager.driver( connectiondata.driverName() ) connection = driver.createConnection(connectiondata) if not connection.connect(): raise "Failed to connect" if not connection.useDatabase( connectiondata.databaseName() ): if not connection.useDatabase( connectiondata.fileName() ): raise "Failed to use database" table = connection.tableSchema("emp") query = table.query() cursor = connection.executeQuerySchema(query) if not cursor: raise("Query failed") while(not cursor.eof()): for i in range( cursor.fieldCount() ): v = str( cursor.value(i) ) if v.startswith(' ') or v.endswith(' '): cursor.setValue(i, v.strip()) cursor.moveNext() if not cursor.save(): raise "Failed to save changes"
Definition at line 85 of file kexidbcursor.h.
Public Member Functions | |
KexiDBCursor (::KexiDB::Cursor *cursor) | |
virtual | ~KexiDBCursor () |
virtual const QString | getClassName () const |
Constructor & Destructor Documentation
KexiDBCursor::~KexiDBCursor | ( | ) | [virtual] |
The documentation for this class was generated from the following files: