-
Notifications
You must be signed in to change notification settings - Fork 0
Django Gotchas
Kamal Mustafa edited this page Sep 12, 2017
·
2 revisions
Most example you'll see look like this:-
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mydatabase',
'OPTIONS': {
'sql_mode': 'TRADITIONAL',
'charset': 'utf8',
'init_command': 'SET '
'storage_engine=INNODB,'
'character_set_connection=utf8,'
'collation_connection=utf8_bin,'
'SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED',
} # Now we have a mild degree of confidence :-)
}
}But this will give you errors like:-
django.db.utils.OperationalError: (1193, "Unknown system variable 'TRANSACTION'")
You should use multiple SET command for the TRANSACTION ISOLATION LEVEL and other options:-
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mydatabase',
'OPTIONS': {
'sql_mode': 'TRADITIONAL',
'charset': 'utf8',
'init_command': 'SET '
'storage_engine=INNODB,'
'character_set_connection=utf8,'
'collation_connection=utf8_bin;'
'SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED',
} # Now we have a mild degree of confidence :-)
}
}Join our Telegram channel t.me/devkini or follow twitter.com/devkini for latest updates in software development.