How can I specify multiple "init_command" in the Django installation file

I have the following setup for my MySQL database connections in Django.

'default': { 'NAME' : MYSQL_DB_NAME, #'ENGINE' : 'mysql', 'ENGINE' : 'django.db.backends.mysql', 'USER' : 'ccurvey', 'PASSWORD' : MYSQL_PASSWORD, 'HOST' : MYSQL_HOST, 'PORT' : '', 'OPTIONS' : { 'init_command' : 'set storage_engine=INNODB', }, }, 

still so good.

What a spell, if I want to add another set command to my init_command command

  'init_command' : ('set storage_engine=INNODB', 'set transaction isolation level read committed'), 

gives me the argument connect () should be a string, not a tuple "

  'init_command' : ('set storage_engine=INNODB; set transaction isolation level read committed;'), 

gives me

 _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now") 
+8
source share
3 answers

For me it worked:

 { 'init_command': 'set storage_engine=InnoDB; \ set session transaction isolation level read committed'} 
+9
source

Do not eat:

  "init_command": 'set storage_engine=INNODB, \ set transaction isolation level read committed;', } 

It:

  "init_command": 'set storage_engine=INNODB, \ SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED', } 
+4
source

@ChrisCurvey's solution is good for me.

ENV: Python3.7.3 + Django2.2.1

 'OPTIONS': { 'init_command': 'SET default_storage_engine=INNODB, sql_mode="STRICT_TRANS_TABLES" ', 'charset': 'utf8mb4', }, 
0
source

All Articles