await connection.execute(“INSERT INTO mytable VALUES (1, 2, 3)”)
except:
await tr.rollback()
raise
else:
await tr.commit()
데이터베이스 트랜잭션은 콘텍스트 프로토콜에 자연스럽게 들어맞는다. 트랜잭션을 시작하고,
connection.execute()
로 데이터를 변경하고, 변경 결과에 따라 롤백
rollback
하거나 커밋
commit
해야 한다.
asyncpg
같은 비동기 드라이버에서 준비하고 마무리하는 작업을 코루틴으로 만들어야 다른
연산을 동시에 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.