上一课我们讲了安装MySQL for python,不过就算安装了mysql那也只是一个数据库,我们就想是不是能够为python安装一个数据库中间件呢?结果adodb又进入了我们的视线,adodb不仅支持php还支持python哦。所以我们今天就来安装adodb for python。本文由ArthurXF倾情奉献。

1.下载
下载adodb-220.zip
2.看了说明我们必须要注意,adodb只是一个中间件,要让python支持各种数据库还是要安装各种数据库的python模块哦,我们这里主要讲mysql,好在我们上一课已经安装了mysql for python了,所以这里就不用再装了。如果没有安装的,请在这一步先安装mysql for python。
3.解压安装adodb
解压之后,进入dos状态,进入adodb-220目录,执行 python setup.py install
4.验证
在python命令行状态,执行import adodb,如果不报错就说明安装正确了。
5.例子
import adodb;
conn = adodb.NewADOConnection('mysql')
conn.Connect('server','user','pwd','db')
cursor = conn.Execute('select * from table')
while not cursor.EOF:
 print cursor.fields
 cursor.MoveNext()
cursor.Close()
conn.Close()
更多例子可以看adodb附带的说明文档。
Tags: ,
python | 评论(0) | 引用(0) | 阅读(7206)
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]