>>> print x
[(1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,)]
>>> for i in range(10):
... if len(x)>0:
... m = random.choice(x)
... x.remove(m)
... y = "%s" %m
... z = int(y)
... cur.execute("""UPDATE accounts SET column = 'YES' WHERE userid = %s""", (z, ))
This doesn't do anything though. When I view the accounts table, nothing's changed.
You need to commit the changes after the update:
db.commit()
where db is a database connection instance (the result of connect() call).
Also see: Database does not update automatically with MySQL and Python.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With