Installation guide
7. mxODBC Cursor Objects
these parameter locations using a positional mapping. Parameter values for
a SQL statement must be specified as sequence, normally a list or a tuple.
Example:
'SELECT * FROM MyTable WHERE A=? AND B=?' used with a
parameter tuple
(1, 2) would result in the database executing the query
'SELECT * FROM MyTable WHERE A=1 AND B=2'.
'named'
The 'named' parameter binding style is used by the native database
interfaces of e.g. Oracle.
Parameters in SQL statements used on
cursor.execute*() methods are
marked with a colon followed by a name, e.g.
':a' or ':1'. The variables
are bound to these parameter locations using a name based mapping.
Parameter values for a SQL statement must be specified as mapping,
normally a dictionary, and are bound to the locations based on the names
used in the SQL statement.
Example:
'SELECT * FROM MyTable WHERE A=:a AND B=:b' used with
a parameter dictionary
{'a': 1, 'b': 2} would result in the database
executing the query
'SELECT * FROM MyTable WHERE A=1 AND B=2'.
.row
This attribute sets the default cursor.row object constructor to be used by all
newly created cursor objects on this connection.
If set to an object constructor taking a row tuple as argument (i.e.
cursor.row(row_tuple)), mxODBC will use the constructor to wrap all rows
fetched through one of the
.fetch*() methods. Instead of row tuples, the
.fetch*() methods will then return the objects created by this constructor.
Default is
None, which means that mxODBC will use regular Python tuples for
returning row data in result sets.
Please see section 5.9 Custom Cursor Row Objects and Row Factory Functions
for details on how to use
cursor.row and cursor.rowfactory.
.rowfactory
This attribute sets the default cursor.rowfactory row object constructor
factory to be used by all newly created cursor objects on this connection.
If set to a factory function, mxODBC will call this factory function with the
cursor as argument when starting to fetch a result set and set the
cursor.row
attribute to the object returned by the factory function (i.e.
cursor.row =
cursor.rowfactory(cursor)
).
The purpose of the row factory is to dynamically set the
cursor.row attribute
after having executed a statement on the cursor. This allows the factory
function to use the
cursor.description for building a row object
constructor customized to the available result set.
Default is
None, which means that mxODBC will not use a row factory
function and leave
cursor.row untouched.
Please see section 5.9 Custom Cursor Row Objects and Row Factory Functions
for details on how to use
cursor.row and cursor.rowfactory.
137