Tree [r673] / tags / MySQLdb-0.3.5 / mysql /

File Date Author Commit
 _mysql_const 2001-03-12 adustman [r87] Finally, a definitive way to determine if trans...
 examples 2000-04-19 adustman [r48] Fix DOS formatting, some minor nits. 2001-03-13 adustman [r93] Fix transaction semantics. 2000-12-01 adustman [r76] Finishing touches.
 MySQLdb-FAQ.sgml 2001-01-27 adustman [r77] Update docs. 2001-03-26 adustman [r102] ARGH!
 MySQLdb.sgml 2001-01-27 adustman [r77] Update docs.
 README 2000-12-01 adustman [r75] Minor updates.
 README.MySQLmodule 2000-10-17 adustman [r67] Forgot to add these 2000-10-17 adustman [r67] Forgot to add these
 _mysqlmodule.c 2001-03-17 adustman [r101] Missed a Py_INCREF()! Does not seem to affect P... 2000-12-01 adustman [r76] Finishing touches. 2001-03-31 adustman [r103] Forgot to commit this.

Read Me


1) The patches are applied already, so you won't find them.
2) Supposedly the that is included here will work on
   both unix and windows, but I've tried it on neither.


From Tue Sep 14 16:09:13 1999
Date: Sat, 11 Sep 1999 13:22:06 -0400 (EDT)
From: Bob Kline <>
Subject: Win32 Build of MySQLdb


In the documentation for MySQLdb, you wrote:

> If you work out an installation routine for Windows, please contact
> the author.

I have built MySQLdb on Windows NT 4.0, PL5, using MSVC 6.0.  The steps
I took were:

 1. Pull down and modify David Ascher's
 2. Modify _mysqlmodule.c.
 3. Modify
 4. Run
 5. Copy _mysql.pyd and into the PYTHONPATH.

I have attached a zip archive containing:

 * _mysqlmodule.c
 * _mysqlmodule.diff
 * Setup.diff

Specifics about the modifications:

1. Ascher's script linked to the single-threaded C run-time libraries,
   but the mysql libraries are multi-threaded.  Changed /MD to /MT and
   /MDd to /MTd.
2. The mysql headers need but fail to include windows.h on WIN32.  Added
   conditional #include statement.
3. The non-standard type uint needed to be defined.
4. Some of the mysql constants used by MySQLdb are presumably from 
   version 3.22.19 (as you indicate in the documentation), but the 
   latest version of the client/development tools available for
   Win32 is 3.22.14, which doesn't have all of those constants defined.
   Added some #ifdef statements to make sure symbols that aren't 
   defined aren't used.
5. The PyObject_HEAD_INIT(&PyType_Type) don't work on Win32, as
   explained in the online Python tutorials.  Added conditional
   replacement approach as instructed by that documentation.
6. Added a null pointer test to a Py_DECREF call to avoid a 
   segmentation fault.
7. Modifed to account for the location of the mysql
   headers and libraries on my system, and to include the Win32
   sockets library (wsock32.lib)

The modified C source code should still work on all platforms.  The
Setup file will need to be customized for each platform which doesn't
have its mysql headers and libraries in the default locations, and Win32
builds will need wsock32 in the setup file.  I wasn't able to determine
how to put conditional portions in the setup file (ideally I wouldn't
have needed to modify at all).  I presume there is
documentation somewhere for this setup file, but I'm new enough to the
Python world that I haven't found it yet.

Assuming the modifications to _mysqlmodule.c get folded into the
distribution, and a version of for Win32 (including
"-lwsock32") is added to the distribution (for example, as Setup.w32),
and the attached version of Ascher's script is included, the steps
someone else would take in order to build with the current version of
MSVC would be:

1. Copy Setup.w32 to
2. Adjust paths in as needed.
3. Run
4. Copy _mysql.pyd and into the PYTHONPATH.

Hope this is useful.

Bob Kline

    [ Part 2, "Mods for building MySQLdb on Win32 platforms"  ]
    [ Application/ZIP  29KB. ]
    [ Unable to print this part. ]

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks