-1

寻求有关更新 mysql 表多个文件的帮助。正在运行以下命令并出现错误。谁可以帮我这个事。正在从字典的值更新表。见以下代码

cols = change_dict.keys()
vals = change_dict.values()
conn = MySQLdb.connect(host = "0.0.0.0",user="test",passwd="test",db='maint')
x = conn.cursor()
sql = "update details set %s = '%s' where maint_id=%s" % ( ",".join(cols), ",".join((vals)),id)
print sql
x.execute(sql)
conn.commit()
4

2 回答 2

0

试试这个说法

sql="UPDATE table name SET field=%s WHERE maint_id=%s", (var1, maint_id)
于 2020-11-26T09:47:51.857 回答
-1

尝试以下操作:

update table set column1 = value1, column2 = value2, column3 = value3 where Condition
于 2013-02-23T05:49:01.610 回答