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.
- mysql-python still doesn’t have compiled binaries for 2.6
- Windows doesn’t ship with a C compiler.
- 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…
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
…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
Instructions for building MySQL 5.1.34 with Python 2.6:
http://www.bcspcsonline.com/wiki/index.php?title=MySQL-5.1.34_Python-2.6_Module_Build_Instructions
Thanks for that info, Anonymous!
Thank you very much. It works!!!