M
M
Max Payne2019-06-06 21:28:32
PostgreSQL
Max Payne, 2019-06-06 21:28:32

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?

ps
тригеры нихачу

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TyzhSysAdmin, 2019-06-06
@POS_troi

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 question

Ask a Question

731 491 924 answers to any question