Implement select_for_update() QuerySet method to lock rows until the end of the transaction.
first = await Person.objects.select_for_update().get(id=1)
second = await Person.objects.select_for_update().get(id=2)
async with database.transaction():
first.balance -= 10
first.save()
second.balance += 10
second.save()
Implement
select_for_update()QuerySet method to lock rows until the end of the transaction.