配置Windows下Python2.6的MySQL数据库驱动MySQLdb for Python

官方网站 http://sourceforge.net/projects/mysql-python/ 目前只有py2.5的py2.6的有人打包了

网上流传的很广的帖子是这样的,到这里

http://sourceforge.net/forum/forum.php?thread_id=2316047&forum_id=70460

http://sourceforge.net/projects/mysql-python/forums/forum/70460/topic/2316047

下载安装完毕即可,但是不能直接使用,需要排错,要下载libmmd.dll,libguide40.dll,libmysql.dll这三个dll文件

[download id="22" format="2"]

拷贝到system32里面去,否则会提示如下错误。

>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "E:\Python26\lib\site-packages\MySQLdb\__init__.py", line 19, in <module>
import _mysql
ImportError: DLL load failed: 找不到指定的模块。

缺dll文件,其实是这个包做的不好,我在这里下载的就没什么问题http://www.codegood.com/archives/4
但是这两个包都有如下问题
>>> import MySQLdb
E:\Python26\lib\site-packages\MySQLdb\__init__.py:34: DeprecationWarning: the se
ts module is deprecated
from sets import ImmutableSet
这个就要改文件了
打开Python26\Lib\site-packages\MySQLdb
修改__init__.py
大概34行替换
from sets import ImmutableSet
class DBAPISet(ImmutableSet):
class DBAPISet(frozenset) :
converters.py:
约37行,注释
from sets import BaseSet, Set
约45行,改为小写的set
return set([ i for i in s.split(',') if i ])
约129行,改为小写的set
set: Set2Str,
打完收工。
Pyhton的MySQL体验还是比较痛苦的,尤其是有中文的时候。
:lol:
Author Info :
  • From:配置Windows下Python2.6的MySQL数据库驱动MySQLdb for Python
  • URL:https://blog.ihipop.com/2010/10/1713.html
  • Please Reserve This Link,Thanks!
  • 发表回复

    您的电子邮箱地址不会被公开。 必填项已用*标注