I have a table in a postgresql database where there are 4 columns:
- id (serial)
- total (int)
- done (int)
- status (bool).
Now, I have some asyncronous processes that do some work and update this table. Basically, they add 1 to the done field, but I also want to update the status to True if total=done after upgrading done.
However, these processes can have the same id, and therefore I should block all the transaction (Update done, check done=total and update status if required) to avoid any problem. How can I do this?
I'm working with python3 and psycopg2.