【发布时间】:2023-03-08 14:48:01
【问题描述】:
我在 PythonAnywhere.com 上的 Bottle 中使用 MySQLdb 时遇到一个非常奇怪的错误
只要执行包含 int、decimal 或 datetime 类型的列,执行就会引发 500 错误。例如,从表 Tools 中,manufacturer 和 sub_type 都是 varchars,所以这段代码可以完美运行:
reservation_id = request.forms.get("reservation_id")
db = MySQLdb.connect("...")
c = db.cursor()
c.execute("""SELECT manufacturer, sub_type FROM Tool""")
row = c.fetchone()
return row
但是从同一个表中请求 tool_id,它是 int 类型,或者从该表中获取任何其他 int、decimal 或 datetime 类型的列:
reservation_id = request.forms.get("reservation_id")
db = MySQLdb.connect("...")
c = db.cursor()
c.execute("""SELECT tool_id FROM Tool""")
row = c.fetchone()
return row
Bottle 抛出一个严重错误:
运行 WSGI 应用程序时出错 SystemError:返回带有错误集的结果
在 MySQL bash 中,每个查询都能完美运行。将相同的查询(仅 int、decimal 或 datetime)放在 execute() 中,它会失败。
有没有人有过类似的经历?
【问题讨论】:
-
如果您在问题中包含堆栈跟踪和 Bottle 框架代码,会更容易提供帮助,但我会尝试一下,因为我有预感。
标签: python mysql bottle pythonanywhere