Installation guide

10. mxODBC Exceptions and Error Handling
10.5 Warning Classes
The Python DB-API 2.0 does not define a warning class hierarchy. At the time the
DB-API 2.0 was defined, the Python warning was not yet in existence. It is
expected that a future revision will add such a hierarchy.
Until then mxODBC uses it's own warning hierarchy which currently just has one
warning class:
DatabaseWarning
Warning issued for important warnings like data truncations while inserting,
etc., if the mxODBC default error handler is active and the
connection.warningformat or cursor.warningformat as set to
WARN_WARNINGFORMAT.
DatabaseWarning is a subclass of the standard Python Warning base class.
This may change in a future release if the DB-API is changed to provide a
warning class hierarchy as well.
10.6 Database Warnings
The default behavior of mxODBC is to raise all errors, including Warnings, which
many ODBC drivers issue for truncations, loss of precision in data conversions,
etc.
This may not always be desirable. For this reason, mxODBC provides a way to
handle database warnings in different ways.
10.6.1 Default Error Handler
The mxODBC default error handler can be adjusted to handle database warnings
in three different ways:
1. raise a
Warning exception for all database warnings (this is the default),
2. issue a Python
Warning for all database warnings (compatible with the
warning framework in Python),
3. ignore all database warnings.
Adjusting the mxODBC behavior is possible using the
connection.warningformat or cursor.warningformat attributes. As always
for these format settings, the cursors inherit the setting from the connection they
were created from using the value set on the connection at creation time.
163