0

I am utilizing Mysql.Connector in my python code to do multiple inserts/updates to a DB. After performing all of the inserts/updates + other processing, I determine if it was successful or not and then perform either a db.commit() or a db.rollback(). I'm concerned about what would happen in a couple different situations. If the process is unexpectedly terminated. e.g kill -9 program.py or if the host|container that the program is running in is shutdown.

Brian Sizemore
  • 249
  • 4
  • 17
  • Given the answer I've found a question that highlights my concerns more. I thought this was client specific when really it is handled by the server. https://stackoverflow.com/questions/4896479/what-happens-if-you-dont-commit-a-transaction-to-a-database-say-sql-server – Brian Sizemore Mar 22 '18 at 14:28

1 Answers1

3

The MySQL server will roll back uncommitted transactions if the connection is terminated.

Dave Stokes
  • 775
  • 4
  • 10
  • I'm looking for MySQL docs to elaborate on the process, but can't seem to find any. Are there any exceptions I need to worry about? – Brian Sizemore Mar 22 '18 at 14:24
  • Check section 13 of the MySQL Manual -- until the server sees a commit it will rollback if there are problems. – Dave Stokes Mar 29 '18 at 13:53