Installation guide
13. mx.ODBC.Misc.RowFactory Module
13. mx.ODBC.Misc.RowFactory Module
This module defines a set of factory functions which can be used together with
cursor.rowfactory to customize the row objects returned by the cursor.fetch*()
methods in mxODBC.
This section describes the available module APIs. Please see section 5.9 Custom
Cursor Row Objects and Row Factory Functions for details on how to use these
row factory functions.
Classes
Row
Common base class of all Row classes built by the factory functions in this
module.
This is useful to have in order to easily type check Row classes via
isinstance().
Base class(es):
object
Functions
TupleRowFactory(cursor)
This is a factory which is a subtype of the Python tuple type and provides a
standard tuple index based access to the row column values, as well as an
attribute based one which is derived from the lower-cased column names
found in
cursor.description.
The row objects are immutable, just like standard tuples, but you can also slice
them or index them as usual.
cursor has to be an mxODBC Cursor object.
ListRowFactory(cursor)
This factory uses a subtype of the Python list type and also provides a
sequence index based access, as well as a named attribute access, just like the
TupleRowFactory.
Unlike for the
TupleRowFactory, the row objects created by the
ListRowFactory are mutable lists, so you can assign to the indexes as well as
the attributes.
cursor has to be an mxODBC Cursor object.
NamespaceRowFactory(cursor)
This row factory function creates mx.Misc.Namespace.Namespace objects as
row objects. These provide a more complex namespace oriented API.
171