Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/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更新SQLite中的两行?_Sql_Python 2.7_Sqlite - Fatal编程技术网

如何使用Python更新SQLite中的两行?

如何使用Python更新SQLite中的两行?,sql,python-2.7,sqlite,Sql,Python 2.7,Sqlite,我试图用Python更新SQLite中的两行: Puntero.execute( "UPDATE '{T}' set '{F}' = '{C}','{V}' = '{U}' where ID='{I}'" .format(T = Tabl, F = fecha, V = Vendidos, U = id, C= Cantidad, I=id)) 谢谢你的帮助 首先,不要那样做。您正在设置SQL注入。改用占位符 你想要的是: Puntero.execute( "UPDATE Tabl se

我试图用Python更新SQLite中的两行:

Puntero.execute(
"UPDATE '{T}' set '{F}' = '{C}','{V}' = '{U}' where ID='{I}'"
.format(T = Tabl, F = fecha, V = Vendidos, U = id, C= Cantidad, I=id))

谢谢你的帮助

首先,不要那样做。您正在设置SQL注入。改用占位符

你想要的是:

Puntero.execute(
   "UPDATE Tabl set fecha = :C, Vendidos = :U where ID=in(:I1, :I2)", 
      {"U": id, "C":Cantidad, "I1":id, "I2":otherid}
)

“…其中ID='{I}'或ID='{I_other}'”
。format(…I=ID,I_other=ID_other)谢谢,克里斯,现在有必要考虑到平板电脑是一个变量,需要很多值。IN()可以接受任何数字。