如何使用python中的变量将Sql更新为?
连接和所有其他sql执行工作正常,但我的update语句没有:如何使用python中的变量将Sql更新为?,python,sql,sql-update,python-3.7,Python,Sql,Sql Update,Python 3.7,连接和所有其他sql执行工作正常,但我的update语句没有: sql= "UPDATE table_name SET column2=%s, column3=%s WHERE column1=%s;" values = (variable2, variable3, variable1) cursor.execute(sql, values) 输出为无。尝试使用f字符串 sql=f“更新表名集合column2={variable2},column3={variable3},
sql= "UPDATE table_name SET column2=%s, column3=%s WHERE column1=%s;"
values = (variable2, variable3, variable1)
cursor.execute(sql, values)
输出为无。尝试使用f字符串
sql=f“更新表名集合column2={variable2},column3={variable3},其中column1={variable1};”
cursor.execute(sql)
update sql just return infected rows等信息,您可以查看该表以检查其数据是否已更改文档中的内容:未定义返回值。因此,不清楚您希望返回什么样的数据。我在pgAamin中检查了该表,但没有进行任何更新。使用字符串连接是非常糟糕的建议,绑定变量是为了安全而发明的。