0
Howdie做,的Python的SQLAlchemy通過MySQL的終端執行而不是通過engine.execute
我有一個非常簡單的SELECT語句:
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
)
然而,當這個SQL是通過Python執行,我收到以下內容:
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"']
它明顯地傳遞了這封信,但爲什麼它會將我的搜索值當作列處理?