Skip to content

How to use transaction (examples)? #402

Answered by aminalaee
ETretyakov asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,
First off, the example you see in the docs is invalid. That will be fixed when 0.5.3 is merged. You don't need to call await tranasaction.start().

transaction = await database.transaction()
try:
    [INSERT/UPDATE] inside that transaction....
except:
    await transaction.rollback()
else:
    await transaction.commit()

You can do INSERT or UPDATE within that transaction, and commit/rollback based on that.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mathans1695
Comment options

Answer selected by aminalaee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants