0

I have a MySQL database that I did not create with Django. It has mixed storage engines for tables. I need to tell Django which storage engine it should use for which table. Is there any way I can do that?

I' ve seen an approach that inside the DATABASES dictionary in settings.py two separate database connections are defined, each with separate storage engine (as described here: Django set Storage Engine & Default Charset), but that adds extra complexity when using django querysets, because I need to remember then what kind of storing engine is being used in each table.

pseudo code of what I want to achieve

class Model_1(models.Model):
    # using InnoDB

class Model_2(models.Model):
    # using MyISAM

1 Answers1

0

In all honesty, unless you have a very specific need to keep the tables MyISAM, you should strongly consider migrating them to InnoDB.

If you're really going to go down this route, you can start using your own DB router as specified in the documentation here: https://docs.djangoproject.com/en/2.2/topics/db/multi-db/#automatic-database-routing

This will allow you to start specifying different database adapters for different models