【发布时间】:2015-10-31 14:32:56
【问题描述】:
你好,
我有一个非常简单的选择语句:
select order_id as oid2, ship_update_date, status_type
from tracking_update
where status_type like 'M'
我已将其转换为函数,原始 SQL 为:
for letter in status_filter:
db.session.execute(
'select order_id, ship_update_date, status_type '
'from tracking_update where status_type = %s' % letter
)
但是,当通过 Python 执行此 SQL 时,我收到以下信息:
OperationalError: (_mysql_exceptions.OperationalError) (1054, "Unknown column 'P' in 'where clause'") [SQL: u'select order_id, ship_update_date, status_type from tracking_update where status_type = "P"']
明明是传信,为什么会把我的搜索值当作一列呢?
【问题讨论】:
标签: python mysql sqlalchemy