Installation guide

mxODBC - Python ODBC Database Interface
the environment variables. Without having these set, mxODBC will fail to load
and give you a traceback:
Traceback (most recent call last):
...
from mxODBC import *
ImportError: initialization of module mxODBC failed
(mxODBC.InterfaceError:failed to retrieve error information (line 6778,
rc=-1))
Linker Paths
Unfortunately, the provided db2profile / db2cshrs shell scripts are buggy in some
versions of DB2, so simply sourcing them won't necessarily work.
You will have to carefully create your own to work around these issues.
A typical problem is that the scripts set
LIBPATH or LD_LIBRARY_PATH (without
paying attention to possibly existing settings) which then causes the following
linker-related traceback when trying to load mxODBC:
Traceback (most recent call last):
...
ImportError: from module mxODBC.so No such file or directory
Database Setup for ODBC Access
Unlike many other databases, DB2 needs to be explicitly told that you want to
connect to the database using ODBC.
This is done by binding the IBM CLI driver against the database in order to setup
ODBC related views and stored procedures. Please consult the IBM DB2
documentation for details on how this is done.
Static vs. forward-only Cursors
IBM DB2 supports static ODBC cursors, but mxODBC defaults to forward only
cursors.
5
While static cursors allow scrolling through the result set and also provides ways
of accessing the correct
.rowcount value, it does come with a significant
performance penalty. We have seen slow-downs in fetching rows of around 2x
times for average queries, so we recommend not using static cursors on
connections that do not need scroll support. To enable static cursors, you can
adjust the
connection.cursortype:
connection = mx.ODBC.Windows.DriverConnect(…)
connection.cursortype = mx.ODBC.Windows.SQL.CURSOR_STATIC
# All cursors created on connection will then default to the static
# cursor type.
Please refer to section 5.8 ODBC Cursor Types for more details on cursor types.
5
Please note that in mxODBC 3.2, mxODBC used to default to static cursors.
48