compile mysqldb 1.2.3 for mysql 5.5 on windows

unlike postgres where tons of third party drivers are waiting for being chosen, for mysql, there are only a few choices and mysqldb is the best at the moment (yep, there are many pure python drivers for mysql, unfortunately, there are all in beta status).



mysql-python doesn't have an offical binary for python 2.6 & mysql 5.5 so i have to build one for myself.


1: get a copy of mysql-python and uncompress it.


2: open setup_windows.py and commet two sentences:


#serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key'])
    #mysql_root, dummy = _winreg.QueryValueEx(serverKey,'Location')


now assign a new value for mysql_root...


here my root is mysql_root = r"D:\MySQL\MySQL Server 5.5"


3: find out library_dirs = [ os.path.join(mysql_root, r'lib\opt') ] and change it to


library_dirs = [ os.path.join(mysql_root, r'lib') ]


after step two and three, save setup_windows.py


4: open _mysql.c comment  find the following part:


#if defined(MS_WINDOWS)
#include <winsock2.h>
#include <windows.h>
#include <config-win.h>
#else
#include "my_config.h"
#endif


wipe #include <config-win.h> and #else out. use #include "my_config.h" directly, like:

#if defined(MS_WINDOWS)
#include <winsock2.h>
#include <windows.h>

#endif

#include "my_config.h"


save _mysql.c


5: python setup.py install... after that we may run some tests...all tests are passed on my machine...


tested envrionment:


windows 7 64 bit...


vs2008, python 2.6.6

 

Note: occasionally, when doing python setup.py install we may see generate _mysql.pyd.manifest error,  use

python setup.py clean, python setup.py bdist instead.



你可能感兴趣的:(c,mysql,windows,python,OS)