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.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值