Answer the question
In order to leave comments, you need to log in
What is the difference between an atomic operation and a transaction?
In the wonderful ORM peewee (python), there is a context manager db.atomic() and next to it db.transaction(). I understand that atomicity is just one of the properties of a transaction, ensuring that the data is written in its entirety and never in part.
The essence of my task is to write certain data to two Postgresql tables (either BULK_INSERT + BULK_INSERT or BULK_UPDATE + BULK_INSERT) so that changes occur either in two tables or in none. I would not hesitate to use transactions if I did not know that there is a separate manager for atomic operations. Maybe he is exactly what I need?
Answer the question
In order to leave comments, you need to log in
If I remember correctly about peewee, then these two functions do the same thing but provide different options for managing the transaction, atomic is automatic and transaction gives you the ability to manage commit / rollback and error handling.
To write to several tables, you can use nested transactions, but here I don’t even remember how it was implemented there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question