【发布时间】:2019-01-10 06:49:27
【问题描述】:
我在部署 httpd 的烧瓶应用程序中收到“对象不可迭代”错误。
def createTable(self, table_name, values):
print('IN CREATE TABLE')
cursor = self.conn.cursor()
cursor.execute(
"""
CREATE TABLE {table_name} ({values})
""".format(table_name=table_name, values=values)
)
self.conn.commit()
print('OUT CREATE TABLE')
打印出包含 IN CREATE TABLE 的第一个打印,但不打印第二个打印。所以,创建表有问题,但我看不到。
mod_wsgi (pid=13470): Exception occurred processing WSGI script '/home/ec2-user/master/app.wsgi'.
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/werkzeug/wsgi.py", line 870, in __next__
return self._next()
File "/usr/local/lib/python3.7/site-packages/werkzeug/wrappers.py", line 82, in _iter_encoded
for item in iterable:
TypeError: 'OperationalError' object is not iterable
我收到了这个错误。
【问题讨论】:
-
我不认为您的错误来自 createTable 函数。此外,您可能想查看创建表的其他方法。 str.format() 为您打开 sql 注入