[Django]-Explicitly set MySQL table storage engine using South and Django

23πŸ‘

βœ…

To be sure that all migrations are always done using INNODB, you should set the storage engine as INNODB in the database definition directly, like thisΒ :

DATABASES = {
    'default': {
        ...
        'OPTIONS'  : { 'init_command' : 'SET storage_engine=INNODB', },
    }

If you are using MySQL 5.7.x and above,

DATABASES = {
    'default': {
        ...
        'OPTIONS'  : { 'init_command' : 'SET default_storage_engine=INNODB', },
    }

But you should know that it can have a performance hit. So you may want to set this option only when running migrations.

πŸ‘€Xixi

14πŸ‘

If you use South, you can set the STORAGE_ENGINE.

django < 1.2

# add to your settings file
DATABASE_STORAGE_ENGINE = 'INNODB' # django < 1.2

django >= 1.2

# add to your settings file
DATABASES = {
   'default': {
       ...
       'STORAGE_ENGINE': 'INNODB'
   }
}
πŸ‘€dnozay

Leave a comment