【发布时间】:2020-04-28 01:03:24
【问题描述】:
我正在尝试使用以下语句在 python 中将数据插入 Mysql
cursor.execute('INSERT INTO batch_details (batch_id,plant_id,product_code) VALUES ("%s","%s","%s")', (id, plantcode, pcode))
这里 id ="75", plantcode="2", pcode="FG"
但是我在数据库中的值是用单引号插入到 mysql 数据库中的,即 '75','2','FG'
我不明白为什么用单引号插入这些值。 sql查询的语法好像是对的。
【问题讨论】:
-
你试过
... VALUES (%s, %s, %s) ...吗? -
@Matthias 是的,我试过了,我现在得到了正确的输出。