Commands out of sync; you can’t run this command now

Website content quality is poor, distribution efficiency is too low how to do?Huawei engineers offer 5 unique skills>>>

sql="update tb1 set xxx=vvv where id=nnn;update tb1 set xxx=www where id=kkk;"
cursor.execute(sql)

Then it will report this error:

Commands out of sync; you can't run this command now

Solution:
replace execute with executemany and pass in the parameter array
remember that the parameter of executemany is required, but execute is not required

sql="update tb1 set xxx=vvv where id=nnn;update tb2 set xxx=www where id=kkk;"
cursor.executemany(sql,[])

Similar Posts: