I am trying to increment row in MySQL database like this
rows = cursor.fetchall()
i = 0
for row in rows:
cursor.execute("UPDATE Table SET order = %s WHERE name = 'JAMES'", (i,))
db.commit()
i += 1
But at the end order for all of the items is 19, and the length of rows is 20. How can I have it go form 0 to 19, I though if I commit() after each loop this would be solved?
Thanks
whereclause, theUPDATEstatement will update all records.cursor.execute("UPDATE Table SET order = %s WHERE name = %s", (i, row.name)).WHEREclause matters.