Using Python 2.6 + MySQL on Windows is nearly impossible

Update:  I made progress on this issue.  See my newer post here.

If you’re interested in writing Python scripts on Windows which access MySQL databases, be sure you avoid Python 2.6.

The standard way to interact with a MySQL database via Python is to install the mysql-python package The problems arise because of several things.

  1. mysql-python still doesn’t have compiled binaries for 2.6
  2. Windows doesn’t ship with a C compiler.
  3. It’s a SOB to use any of the free C compilers to compile from source.

A couple of kind souls have provided their own compiled versions in this forum thread, but neither of the provided versions works on the two Windows machines I’ve tried them on.

I tried following the official directions to compile on windows using the “setup.py build”-method, but MinGW spits out several bajillion lines indicating the following(bolded part indicates error found over and over again):

C:\Program Files (x86)\MySQL\MySQL Server 5.1\lib\opt/mysqlclient.lib(./mysqlcli
ent.dir/relwithdebinfo/inftrees.obj):(.text[_inflate_table]+0x4e3): undefined re
ference to `@__security_check_cookie@4′
collect2: ld returned 1 exit status
error: command ‘gcc’ failed with exit status 1

There’s very little useful information to be found from a google search on this, so as it stands, I’m pretty much unable to use Python 2.6 + MySQL.

I really wonder why MySQL support isn’t packaged with Python.  It’s not like accessing MySQL is an unheard of operation…

  1. Venkatesan Sundramurthy

    Hi, I found a location were one person had successfully built mysql for python2.6, sharing the link,
    http://www.technicalbard.com/files/MySQL-python-1.2.2.win32-py2.6.exe

  2. Venkatesan Sundramurthy

    …forgot to add a comment, you might see a warning while import MySQLdb which is fine and that won’t hurt anything,

    C:\Python26\lib\site-packages\MySQLdb\__init__.py:34: DeprecationWarning: the sets module is deprecated
    from sets import ImmutableSet

  3. Thanks for that info, Anonymous!

  4. Contriving » MySQL and Python 2.6 on Windows, Redux - pingback on September 18, 2009 at 9:39 am
  5. Thank you very much. It works!!!

  6. MySQL for Python in Windows | ASK AND ANSWER - pingback on December 29, 2015 at 11:25 pm

Leave a Reply to AnonymousCancel reply

Trackbacks and Pingbacks: