Created
January 2, 2018 16:19
-
-
Save agmond/d7833dc3e3c01ea2d21fd0be4fa02e1f to your computer and use it in GitHub Desktop.
Interactively dry-run Django code that changes data in the DB, with ability to commit at the end
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import transaction | |
t = transaction.atomic() | |
t.__enter__() | |
# Do your stuff here... | |
pass | |
# If you want to *rollback* you changes: | |
t.__exit__('temp', 'temp', 'temp') | |
# If you want to *commit* your changes: | |
t.__exit__(None, None, None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment