Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用python中的变量将Sql更新为?_Python_Sql_Sql Update_Python 3.7 - Fatal编程技术网

如何使用python中的变量将Sql更新为?

如何使用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语句没有:

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中检查了该表,但没有进行任何更新。使用字符串连接是非常糟糕的建议,绑定变量是为了安全而发明的。