Skip to content

Instantly share code, notes, and snippets.

@filipeximenes
Created December 21, 2019 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filipeximenes/58ea0267bbb78a10c92e35b43274b5e5 to your computer and use it in GitHub Desktop.
Save filipeximenes/58ea0267bbb78a10c92e35b43274b5e5 to your computer and use it in GitHub Desktop.
from django.db import transaction, connection
from events.models import Event
def count_events():
with transaction.atomic():
print(Event.objects.count())
input()
print(Event.objects.count())
def insert_event():
Event.objects.create(name="test")
from django.db import transaction, connection
from events.models import Event
def count_events_repeatable():
with transaction.atomic():
cursor = connection.cursor()
cursor.execute("SET TRANSACTION ISOLATION LEVEL REPEATABLE READ")
print(Event.objects.count())
input()
print(Event.objects.count())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment