Transactions¶
While not inside a transaction, methods that modify the database write out the database to the disk before they return. This is good if you don’t have a lot of requests, but if you are going to execute two or more statements that modify data in a row, you should execute them within a transaction.
Opening a transaction¶
Begin a transaction like this:
db.BeginTransaction()
However, that will create a savepoint called “transaction”. To begin a transaction without that, (you will be unable to revert the transaction) do this:
db.BeginTransaction(False)
Reverting a transaction¶
If you chose to make a save, you can revert a transaction:
db.RevertTransaction()
Checking if a transaction is in progress¶
You can always tell if a transaction is in progress with the boolean value db.TransactionInProgress