How do you create a transaction that spans multiple statements in Python with MySQLdb?
Posted
by
Fast Fish
on Stack Overflow
See other posts from Stack Overflow
or by Fast Fish
Published on 2011-01-09T05:47:02Z
Indexed on
2011/01/09
5:53 UTC
Read the original article
Hit count: 233
I know that with an InnoDB table, transactions are autocommit, however I understand that to mean for a single statement? For example, I want to check if a user exists in a table, and then if it doesn't, create it. However there lies a race condition. I believe using a transaction prior to doing the select, will ensure that the table remains untouched until the subsequent insert, and the transaction is committed. How can you do this with MySQLdb and Python?
© Stack Overflow or respective owner