Installation guide
mxODBC - Python ODBC Database Interface
15. Hints & Links to other Resources
15.1 Running mxODBC from a CGI script
ODBC drivers and managers are usually compiled as a shared library. When
running CGI scripts most HTTP daemons (or web servers) don't pass through the
path for the dynamic loader (e.g.
LD_LIBRARY_PATH) to the script, thus importing
the mxODBC C extension will fail with unresolved symbols because the loader
doesn't find the ODBC driver/manager's libs.
To have the loader find the path to those shared libs you can either wrap the
Python script with a shell script that sets the path according to your system
configuration or tell the HTTP daemon to set or pass these through (see the
daemon's documentation for information on how to do this; for Apache the
directives are named
SetEnv and PassEnv).
On Windows, you also have to take into account that the ODBC data sources
defined in the ODBC manager are usually restricted to specific user accounts. You
can work around this by either setting up the ODBC data sources for the web
server service account or by configuring the data as system data sources.
15.2
Running mxODBC with mod_wsgi
Using mxODBC with mod_wsgi is generally possible. However, since the script
will run under a restricted user account, some care has to be taken to make the
setup work. Please see 15.1 Running mxODBC from a CGI script for more details
on getting ODBC drivers to work in such an environment.
mod_wsgi and Python 2.7
On Windows, there is also another issue to consider when running the
combination Apache, mod_wsgi and Python 2.7. Due to changes in Python 2.7,
manifests for the Visual C++ runtime environment, needed by Windows to find
the right DLL to load, are no longer added to Python extensions, since this caused
problems with loading them into Python processes (see Python Issue 4120
).
Unfortunately, neither mod_wsgi nor Apache appear to include the required
manifests either. This causes an import error when trying to load mxODBC into a
mod_wsgi run process, since Windows cannot resolve the DLL references in
mxODBC without the manifest.
182