A
A
Andrey Grinevich2014-11-27 21:08:45
Django
Andrey Grinevich, 2014-11-27 21:08:45

How to manage multiple databases in Django?

Good day, I have a difficult question for me.
I have a django application that uses PostgreSQL as the backbone of the database.
Inside the application, models are used to describe table structures, ORM is used and everything is fine, but sometimes you need to make "raw queries" to a second MySQL database, for which models are not described and there is no way to use ORM.
The essence of the question is that the number of calls to the second database may increase after some time and the code inside will literally teem with "raw requests", so the question arose, how best to organize work with the second database? Describe models for tables and use an ORM or are there more elegant ways to solve the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kirichuk, 2014-12-06
@orgkhnargh

django-admin.py can generate models for an existing database on its own. There is an article about this in the documentation: https://docs.djangoproject.com/en/dev/howto/legacy...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question