[DB-SIG] Three MySQL modules?

Andy Dustman adustman@comstar.net
Thu, 15 Apr 1999 15:41:25 -0400 (EDT)

On Thu, 15 Apr 1999, Andrew M. Kuchling wrote:

> I haven't yet added Andy Dustman's MySQLdb module to the database
> topic guide.  Can someone clarify the situation with the three MySQL
> modules?  There's James Henstridge's mySQLmodule; the copy on
> python.org is dated 09-Oct-1997, so it's probably unmaintained.  
> There's Joerg Senekowitsch's MySQLmodule, dated 28-Dec-1998, so it's
> probably still maintained, and there's Andy Dustman's module,
> announced earlier this module.
> 	Which ones should be listed in the topic guide?  I think it's
> OK to drop the Henstridge one; does the Dustman code supersede the
> Senekowitsch module?  Authors, can you clarify this?

I was in contact with Joerg Senekowitsch late last year because of
problems I noticed in MySQLmodule-1.4, i.e. no use of
Py_BEGIN_ALLOW_THREADS ... Py_END_ALLOW_THREADS. He asked if I wanted to
take over maintanence. :) He said he there was going to be a 1.5 version,
but I got tired of waiting around for it. Also, the code was real ugly
because it was designed to work originally like a perl DBI module (yuck).
It also had a Python wrapper, written by James Henstridge.

The README in MySQLmodule-1.4 says:

MySQLmodule-1.x is based on mySQLmodule-0.1.4 by

   Copyright (C) 1997  Joseph Skinner <joe@earthlink.co.nz>
   Copyright (C) 1997  James Henstridge <james@daa.com.au>

   mySQLmodule-0.1.4 is based on mSQLmodule, which is

   Portions copyright (C) 1995  Thawte Consulting, cc
   Portions copyright (C) 1994  Anthony Baxter.

See 'Credits' for details.

Joerg Senekowitsch (senekow@ibm.net), October 1998

Confused yet? To top it off, the mSQLmodule author (I think it was Baxter)
wrote me to thank me for writing a new module and putting a bullet in the
old code; he was tired getting questions about it, even though he hadn't
maintained it for years.

My MySQLdb is only designed to work with MySQL-3.22.19+. I know for a fact
that it doesn't presently compile with 3.22.11, because of some new
constants which have since been added. I don't expect it to work with 3.21
at all. However, MySQLmodule-1.4 should work with 3.21, so it may yet have
some life to it, though use of MySQL-3.21 is discouraged nowadays, I

Also, MySQLdb is completely new, and shares no code with any earlier
interface, and it's 100% free software (others might be as well). OTOH,
it's not widely tested yet, but compatible with the 2.0 DB API. They are
not 100% compatible, either. If you use MySQLmodule's Mysqldb:

>>> import Mysqldb
>>> conn = Mysqldb.mysqldb('mysql@localhost root rootpasswd')
>>> curs = conn.cursor()
>>> curs.execute("insert into user (host, user) values ('%s', '%s')",
... [('localhost', 'linus'), ('somewhere.com.au', 'james')])

Equivalent code for MySQLdb (my module) is:

>>> import MySQLdb
>>> conn = MySQLdb.connect(user="root", passwd="rootpasswd")
>>> curs = conn.cursor()
>>> curs.execute("insert into user (host, user) values (%s, %s)",
... [('localhost', 'linus'), ('somewhere.com.au', 'james')])

Note the differences in the query strings. So MySQLdb is definitely not a
drop-in replacement, but definitely better for new apps, particularly if
threading is desired.

So to answer your question, probably both mine and Senekowitsch's ought to
be listed: Mine for MySQL-3.22.19+, and Senekowitsch's for MySQL-3.21.30
(according to the README).

andy dustman  | programmer/analyst |  comstar communications corporation
telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d