【发布时间】:2014-05-27 16:16:32
【问题描述】:
因为我是新人,也因为在谷歌搜索 WSGI 时没有太多工作可做。我需要弄清楚如何将下面的 mysql 查询放入 WSGI 脚本中的函数中。
这是当前的非功能版本。
import MySQLdb
conn = MySQLdb.connect (host = "localhost",
user = "a",
passwd = "",
db = "a")
cursor = conn.cursor ()
cursor.execute ("select * from `01` where id in (1) limit 1")
rows = cursor.fetchall()
cursor.close ()
conn.close ()
aaa = rows[0][1]
def application(environ, start_response):
start_response('200 OK', [('content-type', 'text/html')])
yield aaa
只需让我知道如何将该 mysql 查询放入一个函数中,然后从一个函数中调用它。我知道如何在 PHP 中使用函数,但在 WSGI 方面没有太多经验
【问题讨论】:
标签: python function mod-wsgi wsgi mysql-python