我有一个工作 python 脚本,它从 sqlite3 db 中检索数据。不过,我需要将其转换为与 mysql db 对话,这是让我感到悲伤的第一行:
PRODUCT_CODE_ID = "SELECT id FROM localsite_productcode WHERE localsite_productcode.product_code=?"
cur.execute(PRODUCT_CODE_ID,(product_code,))
当我尝试使用 mysql 时,出现以下错误:
Traceback (most recent call last):
File "gen-csv.py", line 85, in <module>
cur.execute(PRODUCT_CODE_ID,(product_code,))
File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 151, in execute
query = query % db.literal(args)
TypeError: not all arguments converted during string formatting
我在这里做错了什么?