MySQL access from Python

Andy Dustman adustman at comstar.net
Wed Mar 1 20:00:30 EST 2000


On Wed, 1 Mar 2000, Chuck Esterbrook wrote:

> There's a MySQLmodule-1.4.tar.gz at www.mysql.com.
> There's a MySQLdb at http://starship.python.net/crew/adustman/MySQLdb.html
> 
> Any advice on which one to use? Has anyone had experience with both of these?

Well, I'm the author of MySQLdb. MySQLdb is designed to work well in a
threaded environment (gives up the interpreter lock during blocking
calls), and to work with MySQL-3.22 and up; I have not tested it with
3.23, but once it stabilizes a bit, I will ensure that it continues to
work. Architecturally, it's really two modules:

_mysql: low-level C interface, transliteration of the MySQL C API to an
object-oriented Python interface.

MySQLdb: Python wrapper to _mysql that provides a DB API v2.0-compatible
interface. 

One weird/interesting thing it does is it lets you specify how values are
converted going from MySQL to Python and vice versa. There are two
dictionaries that key on types, which map to functions which do the
conversion, with sensible default conversions. (MySQL actually returns all
values to the C API as strings, and all values passed to MySQL must be
part of a literal query string.)

0.1.2 is the current version. I have reports that it dumps core on
RedHat/Alpha platforms, but I can't reproduce it on RedHat/Intel; patches
welcome. 0.1.1 doesn't have this problem, and it's still available in the
same location (no direct link on the page, however). Other people have
reported getting it to work on that crackpot OS from out of Redmond. It
also includes a patch to make Zope's ZMySQLDA to work with it instead of
MySQLmodule. Also check this page:

http://www.zope.org/Members/adustman/MySQLdb

I haven't looked at MySQLmodule a whole lot lately. Here's what I THINK I
know about it, some of which may be wrong:

- Doesn't give up the interpreter lock during blocking calls, causing
threads to block (bad for threaded things like Zope).

- MySQL-3.21 compatible only.

- Also a split interface (C module + Python wrapper).

- The C module exports a Perl-style interface (ick).

- Not really actively supported. Joe Skinner (original MySQLmodule author)
has expressed optimism that he might finally stop getting bugged about
MySQLmodule. :)

-- 
andy dustman       |     programmer/analyst     |      comstar.net, inc.
telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d
"Therefore, sweet knights, if you may doubt your strength or courage, 
come no further, for death awaits you all, with nasty, big, pointy teeth!"




More information about the Python-list mailing list