Posted on

To run multiple executions a time, the SQL statements should be separated by semicolons(;) and with the multi option as true. And meanwhile, cursor.execute returns an iterator, so we have to iterate it so that our statements get executed.

for _ in cursor.execute(update_string, multi=True):
    pass
cnx.commit()

References

  1. https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursor-execute.html
  2. https://overiq.com/mysql-connector-python-101/executing-queries-using-connector-python/

Leave a Reply

Your email address will not be published. Required fields are marked *