python之mysql连接 MySQLdb
2011-03-10 16:32
357 查看
1,根据操作系统下载MySQL-python http://www.codegood.com/archives/4,也可以在https://sourceforge.net/projects/mysql-python/files/mysql-python/得到linux下版本,我这里用到的win32和python2.6
2,双击安装MySQLdb
3.然后import MySQLdb。出现File "C:/Python26/lib/site-packages/MySQLdb/__init__.py", line 19, in <module>
ImportError: DLL load failed: 找不到指定的模块。是缺少2个dll文件分别为 libguide40.dll和libmmd.dll。下载之,然后复制到 WINDOWS/system32 或者Python26/Lib/site-packages下
4,然后import MySQLdb。再出现sys:1: DeprecationWarning: the sets module is deprecated 的错误,再次搜索,原因是2.6不知sets这个模块,不过已经添加了set内置函数。找到MySQLdb文件夹的中__init__.py,注释掉from sets import ImmutableSet
class DBAPISet(ImmutableSet):添加class DBAPISet(frozenset):;找到converters.py注释掉from sets import BaseSet, Set。然后修改第45行和129行中的Set为set。
5,import MySQLdb
conn=MySQLdb.connect(host="localhost",user="root",passwd="root",db="test")
连接成功mysql使用api :http://mysql-python.sourceforge.net/MySQLdb.html
附:相关安装文件和dll整理后下载http://download.csdn.net/source/3080072
2,双击安装MySQLdb
3.然后import MySQLdb。出现File "C:/Python26/lib/site-packages/MySQLdb/__init__.py", line 19, in <module>
ImportError: DLL load failed: 找不到指定的模块。是缺少2个dll文件分别为 libguide40.dll和libmmd.dll。下载之,然后复制到 WINDOWS/system32 或者Python26/Lib/site-packages下
4,然后import MySQLdb。再出现sys:1: DeprecationWarning: the sets module is deprecated 的错误,再次搜索,原因是2.6不知sets这个模块,不过已经添加了set内置函数。找到MySQLdb文件夹的中__init__.py,注释掉from sets import ImmutableSet
class DBAPISet(ImmutableSet):添加class DBAPISet(frozenset):;找到converters.py注释掉from sets import BaseSet, Set。然后修改第45行和129行中的Set为set。
5,import MySQLdb
conn=MySQLdb.connect(host="localhost",user="root",passwd="root",db="test")
连接成功mysql使用api :http://mysql-python.sourceforge.net/MySQLdb.html
附:相关安装文件和dll整理后下载http://download.csdn.net/source/3080072
相关文章推荐
- windows下用Python连接mysql报错问题“MySQLdb in Python: “Can't connect to MySQL server on 'localhost'””
- Python下使用MySQLdb连接MySQL出错的解决办法(一)
- 教为学:Python学习之路(二):MySQLdb的几种安装方式,以及用Python测试连接MySql
- python模块使用之MySQLdb 连接 MySQL 数据库
- python MySQLdb连接mysql失败 mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL
- python MySQLdb mysql 数据库连接
- python中使用MySQLdb连接mysql
- python 使用mysqldb模块通过SSHTunnelForwarder隧道连接mysql
- python MySQLdb连接MySQL数据库报错(2003, "Can't connect to MySQL server on 'localhost' (10061)")解决办法
- 关于MySQLdb的一些新发现(使用python连接mysql的库)
- python MySQLdb连接mysql失败问题
- python 使用mysqldb模块通过ssh隧道连接mysql
- python 使用mysqldb模块通过SSHTunnelForwarder隧道连接mysql
- python django MySQLdb 连接 mysql 5.5 中文乱码问题的解决
- 配置python与mysql连接(mysqldb)的安装与配置。
- 教为学:Python学习之路(二):MySQLdb的几种安装方式,以及用Python测试连接MySql
- Python - MySQLdb.connect连接lampp中mysql服务器问题的解决
- 安装MySQL-python(MySQLdb)时报错,找不到libmysqlclient_r.so.16动态连接库
- python2.7 使用MySQLdb模块封装一个获取mysql连接的类案例
- python中使用MySQLdb连接mysql