1.4.5 Cursor Methods

The cursor object has a number of methods which can be used if you want more control over how the database that you can get by using the SQL functions discussed earlier such as select() or insert() etc.

One of the main reasons for writing this module was to avoid the conversion issues encountered with different databases when using these functions so there use should be avoided if possible.

execute( sql[,values=None])
Execute an SQL string substituting ang values
sql
The SQL string
values
A tuple or list of values to substitute into the SQL string

Warning: It should be noted that different cursors may perform some conversions on the information returned by these functions

fetchone( )
Fetches one row of results from the current set of results as a tuple

fetchall( )
Fetches all rows of results from the cursor as a tuple of tuples

If you want the values correctly converted the cursor object provides a fetchRows method. This is the method called by the select() method if autoExecute is True to return the results.

fetchRows( [fetchMode=None][,types=None])
Return the results as properly converted values
fetchMode
The format of the results returned. Can be 'dict' to return them as a tuple of dictionary objects, 'tuple' to return them as a tuple of tuples or 'dtuple' to return them as a tuple of dtuple objects which can be treated as a tuple or a dictionary. If not specified takes the value specifed in the cursor which by default is 'dtuple'
types
A dictionary containing the table names with each table being the key to another dict containg the column names and type codes for each field of the table

See About this document... for information on suggesting changes.