确定,所以我尝试导入一个类,我做它连接到MySQL数据库类的代码如下所示:PSP级进口+ MySQL的连接
class connection
def__init__(self):
self.cnx = MySQLdb.connect(user='xxx',host='xxx',passwd='xxx',db='xxx')
所有MySQL连接的参数是否正确,包含该类的文件与PSP文件位于同一目录中。该类文件被称为cnx_class.py
当我运行我的PSP文件时,我得到'cnx'未定义。我的PSP代码如下:
<psp:file>
import cnx_class
</psp:file>
<%
cur = cnx.cursor()
cur.execute('select * from protein;')
rows = cur.fetchall()
for row in rows:
req.write`(row)`
#end
%>
任何帮助吗?