1.安装mysql-db,本文中的附件支持python2.6版本
2.安装之后如果执行:import MySQLdb没有问题,就表示mysql-db安装成功
3.conn = MySQLdb.connect(host="127.0.0.1",user="root",passwd="123456",db="test
cursor = conn.cursor ()
cursor.execute ("SELECT VERSION()")
row = cursor.fetchone ()
print "server version:", row[0]
cursor.close ()
conn.close ()
常见问题:
1.ImportError: DLL load failed: 找不到指定的模块。
----------------------------------------------------------------------------------------------------
D:/usr/local/Python26>python
Python 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:/usr/local/Python26/Lib/site-packages/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: DLL load failed: 找不到指定的模块。
2.ImportError: DLL load failed: 找不到指定的模块。
----------------------------------------------------------------------------------------------------
D:/usr/local/Python26>python
Python 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
D:/usr/local/Python26/lib/site-packages/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated
from sets import ImmutableSet
----------------------------------------------------------------------------------------------------
解决方法:
1) file "__init__", replace:
from sets import ImmutableSet
class DBAPISet(ImmutableSet):
with
class DBAPISet(frozenset)
2) file "converters.py", remove:
from sets import BaseSet, Set
3) file "converters.py", change "Set" by "set" (IMPORTANT: only two places):
line 48: return set([ i for i in s.split(',') if i ])
line 128: set: Set2Str,
----------------------------------------------------------------------------------------------------
解决方法:下载libmmd.dll(附件)和libguide40.dll(附件)两个dll文件并复制到python安装目录的Lib/site-packages下。
分享到:
相关推荐
python连接MySQL数据库
python连接mysql数据库,简单的例子,需要先安装pythone3.0、pymysql模块、mysql数据库才能运行
通过python脚本连接mysql数据库, 并执行mysql数据库语句,工具类。
Python 连接MySQL数据库时自动开启服务器 Python源码Python 连接MySQL数据库时自动开启服务器 Python源码Python 连接MySQL数据库时自动开启服务器 Python源码Python 连接MySQL数据库时自动开启服务器 Python源码...
python连接MySQL数据库的操作代码
python连接mysql数据库代码。必须先下载安装mysql数据库,并启动数据库
Python连接Mysql数据库1
pymysql python连接mysql数据库
使用python连接mysql数据库的源代码文件,很好的代码实现资料
如何用python连接mysql数据库
通过python编写代码连接MySQL数据库,包括数据库和数据表的创建。
Python连接各个版本的mysql数据库,python-mysql-connector MySQL连接python的连接器,可以用于Python2、Python3包括最新的python3,使用起来挺方便的,用python进行数据库编程的朋友,可参考本源码。
python可以用这个包来连接MySQL数据库
这是我第一次写的代码:python连接MySQL数据库,查询数据后定时邮件发送数据,纯python代码。 首先用python连接MySQL数据库,查询出数据后转成DataFrame格式数据,再制作成网页版,构建成邮件,设置好定时时间,直接...
这是一篇介绍python连接和使用mysql数据库的文档,介绍了python对mysql数据库的insert、update、delete等基本操作。
Python访问MySQL数据库 Python访问MySQL数据库
NULL 博文链接:https://liu-hliang.iteye.com/blog/846222
不同的数据库你需要下载不同的DB API模块,例如你需要访问Oracle数据库和Mysql数据,你需要下载Oracle和MySQL数据库模块。 DB-API 是一个规范. 它定义了一系列必须的对象和数据库存取方式, 以便为各种各样的底层...