2👍
An alternative is to use SQLAlchemy for the external database. It can use reflection to generate the SQLAlchemy-equivalent of django models during runtime.
It still won’t be without issues. If your code depends on a certain column, it would still break if that column is removed or changed in an incompatible way. However, it will add a bit more flexibility to your database interactions, e.g. a Django model would definitely break if an int
column is changed to a varchar
column, but using database reflection, it will only break if your code depends on the fact that it is an int
. If you simply display the data or something, it will remain fully functional. However, there is always a chance that a change doesn’t break the system, but causes unexpected behaviour.
If, like Benjamin said, the external system has an API, that would be the preferred choice.
0👍
I suggest you to read about inspectdb and database routers. It’s possible to use the django ORM to manipulate a external DB.
https://docs.djangoproject.com/en/1.7/ref/django-admin/#inspectdb
- [Answered ]-Use a parameter attribute as a default value for another parameter?
- [Answered ]-How to stop the Django server from keep loading?
- [Answered ]-How can I delete a django reverse OneToOne-Relation and then reuse the model instance?
0👍
I would create the minimal django models on the external databases => those that interact with your code:
Several outcomes to this
- If parts of the database you’re not interested in change, it won’t have an impact on your app.
- If the external models your using change, you probably want to be aware of that as quickly as possible (your app is likely to break in that case too).
- All the relational databases queries in your code are handled by the same ORM.
- [Answered ]-Incorporating react redux into django
- [Answered ]-Error with Python import
- [Answered ]-Invisible table borders ReportLab
- [Answered ]-Trying to exit out of a function in Django in order to render correct html page name