Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I specify multiple "init_command"s in Django's setup file

I have the following setup for my connections to a MySQL database 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',
        },
    },

so far, so good.

What's the incantation if I want to add another "set" command to my "init_command"

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

gives me "connect() argument must be string, not 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")
like image 295
Chris Curvey Avatar asked Aug 28 '12 18:08

Chris Curvey


2 Answers

For me what worked was:

{ 'init_command': 'set storage_engine=InnoDB; \
                   set session transaction isolation level read committed'}
like image 90
vlad-ardelean Avatar answered Nov 01 '22 08:11

vlad-ardelean


Not is:

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

It is:

 "init_command": 'set storage_engine=INNODB,    \
                  SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED', }
like image 40
dani herrera Avatar answered Nov 01 '22 09:11

dani herrera