This module should be mostly compatible with an older interface written by Joe Skinner and others. However, the older version is a) not thread-friendly (database operations could cause all other threads to block), b) written for MySQL 3.21 (does not compile against newer versions without patches), c) apparently not actively maintained. MySQLdb is a completely new module, distributed free of charge under the GNU Public License.
This module is developed on RedHat Linux (currently 7.1) for Intel. It
should build without much trouble on most platforms by using the
setup.py script. Supposedly it builds on MacOS X. Be aware that
you need the Distutils package which comes with Python 2.0. If you
don't have it (i.e. you have Python 1.5.2), you can find it over at
Windows is not a supported platform. However, the
script reportedly gets the job done. There is probably a link on the
web page for getting a precompiled Windows installer from someone or
other. Be aware that this is a user-contributed package; the author
cannot help you with compiling and running under Windows.
MySQLdb requires Python 1.5.2 or newer. Earlier versions will not
work, because support for C
long long is required by MySQL. If
you have an earlier version of Python, upgrade to 1.5.2 or beyond.
Current development is done with Python 2.2.1, but Python 1.5.2 will be
supported for the forseeable future.
Only versions 3.22.32 and up are guaranteed to work. Some older versions may work; if you have an older version you should seriously consider upgrading to get the bug fixes and particularly the security updates.
MySQL-3.22 seems to have a problem trying to insert
with fractional seconds. Values like 12:56:13.00 are returned as
344:13:00, apparently interpreting the original input as 12 days, 56
hours, 13 minutes, 0 seconds. (12 days and 56 hours is 344 hours.) To
avoid this problem, use the
MySQL-3.23 is now stable (3.23.51 as of this writing). MySQLdb
supports transactions if the server supports them. Even then,
this does not guarantee that transactions will work. For that, you
must use a transaction-safe table (TST). Current TSTs are BDB and
InnoDB. Note that MySQL
generally operates in
AUTOCOMMIT mode by default, and MySQLdb
AUTOCOMMIT is on by default. To change this, use the
SET AUTOCOMMIT=0 SQL statement.
MySQL-4.0 is supported, though still alpha.
If you have the mx.DateTime package installed (recommended), MySQLdb will use it for date-related objects. Otherwise, these will be returned to Python as strings. You can also modify the type conversion dictionary to return these as other object classes, if you prefer.
MySQLmodule, the older MySQL interface by Joe Skinner and others, is
also a split C/Python interface.
MySQL, the C portion, has an
interface similar to perl's DBI internally. In addition, there is
Mysqldb, which provides a DB API v1.0 interface,
written by James Henstridge. MySQLdb-0.2.2 and up include
CompatMysqldb, which is an adaptation of
_mysql. It should be considered experimental.
In contrast, MySQLdb's C portion,
designed to mimic the MySQL C API in an object-oriented way; you
should not expect to move from
_mysql without a
fair amount of work.
provides a DB API
v2.0 interface, which has some changes from the v1.0 interface. Things
to watch out for in particular:
|Connecting|| || |
|Implicit cursor|| ||implicit cursors dropped from DB API v2.0; always use |
|Fetch row as dictionary|| ||not standard; alternate cursor class |
|Transactions|| || |
I wrote a ZMySQLDA for use with MySQLdb. It's adapted from ZOracleDA from Digital Creations, makers of Zope.
The web page documentation may be slightly ahead of the latest release and may reflect features of the next release.
A FAQ is available at http://dustman.net/andy/python/MySQLdb/faq/MySQLdb-FAQ.html.