The mxODBC and mxDateTime Extensions

The ODBC module distributed with PythonWin is a minimal implementation, and conforms to Version 1.0 of the Python Database API. It’s stable and works well, but is unlikely to be developed further. Then again, neither is ODBC![4]

If you work extensively with databases, check out Marc-André Lemburg’s mxODBC extension package, available from http://starship.python.net/crew/lemburg/. One of its many features is an enhanced set of date and time types to save you from worrying about Microsoft and Unix date systems. These are available as a separate package, mxDateTime, which can be used in nondatabase applications. mxODBC also runs on Unix. mxODBC has some licensing restrictions; check the web site for the latest details.

mxDateTime and mxODBC are both shipped as packages that should be unzipped somewhere on the Python path.[5] The latter creates a directory and package named—you guessed it—ODBC. There is a naming collision with the old ODBC module, which lives in ...Python\win32\odbc.pyd ; we suggest renaming this to something else, such as win32odbc.pyd, so that you can still access the old module if you want to (note, however, that you need to rename the module back to the original odbc.pyd before it can be used again). It contains a number of subpackages aimed at other platforms; the functionality we want is in the module ODBC.Windows . Let’s give it a try:

>>> import ODBC.Windows >>> conn = ODBC.Windows.Connect('PYDBDEMOS') >>> cursor ...

Get Python Programming On Win32 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.