Force django to create tables using the MYISAM storage engine

How to force django to use the MYISAM storage engine when creating a database using the syncdb command ? This page does not help shed light on this issue.

MYISAM is the ideal choice as the database is almost read-only and MYISAM is significantly faster than InnoDB. There are still models.ForeignKey fields in the model , but they are used only to create the main admin pages. There is no need for foreign keys in the database.

+7
django django-models myisam
source share
2 answers

See this page . Using the OPTIONS variable in your DATABASES parameter should do the trick, but porting an existing database to a new engine is not so easy (think you have to reinitialize).

 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': '', 'USER': '', 'PASSWORD': '', 'OPTIONS': { "init_command": "SET storage_engine=MYISAM", } } } 
+12
source share

You must set the storage engine as INNODB in the database definition directly, for example.

 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', ..... 'STORAGE_ENGINE': 'MYISAM' } } 

For the new version, you can use:

 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', ..... 'OPTIONS': { "init_command": "SET storage_engine=MYISAM", } } } 
-one
source share

All Articles