Reputation: 2621
I'm using Python to manipulate a MySQL database. In one of my functions, I have 2 execute statements that must be performed in the order I coded them:
database_conn.cursor().execute(sql statement 1)
database_conn.cursor().execute(sql statement 2)
database_conn.commit()
Are these two statements guaranteed to be executed and commited in this order? Thanks.
Upvotes: 0
Views: 917
Reputation: 562871
Yes, a given database session is single-threaded and each execution blocks until its statement completes. So they are guaranteed to apply to the database in the order you execute them.
Upvotes: 1