嗨,我已经安装了WAMP服务器(Mysql,apache,php),并且还单独安装了“Python”。现在我试图使用python代码连接到该数据库。Wamp Server和Python
这是我的Python代码:
#!C:\Python32\python.exe
import sys
import os
import cgi
import MySQLdb
import cgitb
import SecureDb
cgitb.enable()
print ("Content-type: text/plain\n\n");
conn= MySQLdb.connect(host = SecureDb.host ,user =SecureDb.user ,passwd=SecureDb.password ,db=SecureDb.database)
cursor=conn.cursor()
cursor.execute("select * from register where Name='Subburaj'")
result=cursor.fetchall()
cursor.close()
conn.close()
但是,这是否显示错误:
Traceback (most recent call last):
File "C:\Users\Ponmani\Desktop\test.cgi", line 5, in <module>
import MySQLdb
File "C:\Python32\lib\site-packages\MySQLdb\__init__.py", line 17, in <module>
from release import __version__, version_info, __author__
ImportError: No module named release
如果有人过这样的问题来了,请帮我解决this.Thanks提前。
回溯中的奇数行2与文件中的第2行不匹配。你确定你给我们的是'C:\ Users \ Ponmani \ Desktop \ test.cgi'的内容吗? –
对不起大卫罗宾逊..现在你可以看到我编辑的帖子.. –