Installation guide

8. Data Types supported by mxODBC
8.6.2 Adjusting/Querying the Converter Function
Cursor objects will use the connection's .converter attribute as default
converter. It defaults to
None, meaning that no converter function is in effect.
None can also be used to disable the converter function on a cursor:
# Don't use a converter function on the cursor
cursor.setconverter(None)
You can switch converter functions even in between fetches. mxODBC will then
reallocate and rebind the column buffers for you.
The currently used converter function can be queried through the read-only
cursor.converter attribute, e.g. to check whether the default mxODBC
conversions are being used or not.
8.6.3 Example Converter Function
Example (always return INTEGER values as FLOATS):
def converter(position,sqltype,sqllen):
if sqltype == SQL.INTEGER:
sqltype = SQL.FLOAT
return sqltype,sqllen
# Now tell the cursor to use this converter:
cursor.setconverter(converter)
8.7 Auto-Conversions
While you should always try to use the above Python types for passing input
values to the respective columns, the package will try to automatically convert the
types you give into the ones the database expects when using the SQL Type bind
method, e.g. an integer literal '123' will be converted into an integer 123 by
mxODBC if the database ODBC driver requests an integer.
The situation is different in Python type binding mode
(
BIND_USING_PYTHONTYPE): the Python type used in the parameter is passed
directly to the database, thus passing '123' or 123 does make a difference and
could result in an error from the database.
153