Python 3 MySQLdb port (was Re: Some more Python 3: (was Re: rawhide report: 20100507 changes))

David Malcolm dmalcolm at
Fri May 7 18:49:42 UTC 2010

On Fri, 2010-05-07 at 14:36 -0400, David Malcolm wrote:
> On Fri, 2010-05-07 at 11:08 -0700, Kyle VanderBeek wrote:
> > On Fri, May 7, 2010 at 9:05 AM, David Malcolm <dmalcolm at>
> > wrote:
> >         On Fri, 2010-05-07 at 12:25 +0000, Rawhide Report wrote:
> >         
> >         Three more python 3 subpackages in today's "rawhide" heading
> >         for F14 -
> >         I've gone ahead and added these to the wiki here:
> >
> >         
> >         Are we missing anything?
> >         
> > 
> > 
> > Crud, this probably means I need to either finish my pure-python MySQL
> > driver, or work on making MySQLdb run with python3. :-)  If you want
> :)
> >  to update the upstream status for MySQLdb, we simply haven't started
> > porting it.
> You're probably in a better position to give accurate status on that
> page (it's a wiki, feel free to edit)
> I actually had a go at porting MySQLdb to py3k, I'll see if I can find
> my source tree.

In the hope that's its helpful, attached is a messy, mostly-compiling
port of the code.

It's from SVN r633; this was an experiment I did back in November 2009.

The .py parts are from 2to3 and are python 3 only, but ought to be
regeneratable via 2to3.

The .c parts are from my 2to3c code and some manual hacking.  The aim is
that they're compilable against both 2 and 3 from the same sources.

(I may be misremembering all this)

It may well not fully compile, and I'm definitely playing fast-and-loose
with things like encodings.  IIRC I was able to get it to compile, and
to at least connect to MySQL from python3, but I'm definitely getting
things wrong with anything non-ASCII, I'm afraid.

(I'm assuming an invocation of 2to3 upon the .py code, and the use of
the "distribute" fork of setuptools; I'm using python 3.1.1 FWIW)

Hope this is helpful; I'd appreciate a shout-out to Red Hat if it does

-------------- next part --------------
A non-text attachment was scrubbed...
Name: hacked-up-port-of-MySQLdb-to-py3k.patch
Type: text/x-patch
Size: 42413 bytes
Desc: not available
Url : 

More information about the python-devel mailing list