Installation guide

mxODBC - Python ODBC Database Interface
5.4 Thread Safety & Thread Friendliness
mxODBC itself is written in a thread safe way. There are no module globals being
used and thus no locking is necessary.
5.4.1 Connections and Cursors
In general when using a separate database connection for each thread, you
shouldn't run into threading problems. If you do, it is more likely that the ODBC
driver is not 100% thread safe and thus not 100% ODBC compatible. Note that
having threads share cursors is not a good idea: there are many very strange
transaction related problems you can then run into.
5.4.2 Unlocking the Python Global Interpreter Lock (GIL)
Many of the underlying ODBC SQL function calls are wrapped by macros
unlocking the global Python interpreter lock before the call and regaining that lock
directly afterwards. The most prominent of those are the connection APIs and the
execute and fetch APIs.
Unlocking the interpreter lock during long SQL function calls gives your
application more responsiveness. This is especially important for GUI based
applications, since no other Python thread can run when the global lock is
acquired by one thread.
5.4.3 Threading Support
mxODBC will only support threading if you have built Python itself with thread
support enabled. Python for Windows and most recent Python versions for Unix
have this enabled per default. Try:
python -c "import threading" to find out.
If you get an exception, thread support is not available.
5.5 Transaction Support
5.5.1 Auto-Commit
ODBC uses auto-commit on new connections per default. This means that all SQL
statement executes will directly have an effect on the underlying database even in
66