Created
September 3, 2015 11:06
-
-
Save igniteflow/922bbe327478368d2342 to your computer and use it in GitHub Desktop.
Django: Setting transaction level and autocommit with MySQL
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
# my.conf | |
[mysqld] | |
autocommit = 1 | |
transaction-isolation = READ-COMMITTED | |
# settings.py | |
DATABASES = { | |
..., | |
'OPTIONS': { | |
'init_command': 'SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED', | |
'read_default_file': 'path/to/my.cnf', | |
} | |
} | |
# this in code somewhere to check settings have been applied | |
from django.db import connection | |
import logging | |
cursor = connection.cursor() | |
cursor.execute("SHOW VARIABLES LIKE 'tx_isolation'") | |
logging.info(cursor.fetchone()) | |
cursor.execute("SHOW VARIABLES LIKE 'autocommit'") | |
logging.info(cursor.fetchone()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment