django - transaction

brian·2022년 6월 5일

DB에 연속된 처리를 실행할 때, 중간점에서 에러가 발생한다면 데이터의 무결성(integrity)이 보장되지 않는다.

이러한 이유로 연속된 데이터베이스 처리를 하는 경우 django에서 제공하는 transaction 메서드를 사용한다.

from django.db import transaction

@transaction.non_atomic_requests
def my_view(request):
    do_stuff()

@transaction.non_atomic_requests(using='other')
def my_other_view(request):
    do_stuff_on_the_other_database()

0개의 댓글