大概是这样的
common = form["common"]
query = "UPDATE tb SET %s = %s WHERE id = %s"
cursor.execute(query, [common, field, updtae_id])
变量common代替字段名title。
然后common替代第一个 %s 时,SQL报错:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''title' = 'title3' WHERE id = '3'' at line 1"
就是 common 被自动加上引号了……如何才可以不让它有引号呢?
Python新手,谢谢指教……
common = form["common"]
query = "UPDATE tb SET %s = %s WHERE id = %s"
cursor.execute(query, [common, field, updtae_id])
变量common代替字段名title。
然后common替代第一个 %s 时,SQL报错:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''title' = 'title3' WHERE id = '3'' at line 1"
就是 common 被自动加上引号了……如何才可以不让它有引号呢?
Python新手,谢谢指教……