custom sql queries to other databases


I want to start a project where I want to be able to reuse the existing database, specifically some tables without having to create a model, could something like this be done?

You could always use pyodbc (for mssql in the picture) directly in your views. Of course, you’d lose a lot of the advantages the Django orm has to offer.

See the docs on Performing Raw Queries and Multiple Databases for information if you’re going to add the databases to your settings as separate database instances. This will allow Django to manage the connections. Otherwise, you’re on your own for managing your connections to the database(s).

If you’re just grabbing a particular value from a table or two, that’ll probably work out fine. But if you’re going to be really working with the data from those foreign databases, it’ll end up being a lot less work in the long run to create models for it.

The reason is that there are tables in a database which, by way of not having data redundancy, is that it would be to consume it directly and serialize it, is it optimal? Are there other ways?