Kexi API Documentation (2.0 alpha)

Kross::KexiDB::KexiDBCursor Class Reference

#include <kexidbcursor.h>

Inheritance diagram for Kross::KexiDB::KexiDBCursor:

Class List of all members.

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

Classes

class  Record


Constructor & Destructor Documentation

KexiDBCursor::KexiDBCursor ::KexiDB::Cursor cursor  ) 
 

Definition at line 30 of file kexidbcursor.cpp.

KexiDBCursor::~KexiDBCursor  )  [virtual]
 

Todo:
check ownership

Definition at line 51 of file kexidbcursor.cpp.


Member Function Documentation

const QString KexiDBCursor::getClassName  )  const [virtual]
 

Definition at line 68 of file kexidbcursor.cpp.


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for Kexi 2.0 alpha.
Documentation copyright © 2002-2007 the Kexi Team.
Generated on Tue Apr 1 20:51:06 2008 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003