3 ms·
The Django ORM is close to useless if your database is not generated by the web app.
by jgalt212 3y ago
The Django ORM is close to useless if your database is not generated by the web app.
- Nextgrid 3y agoYou can “cheat” by having fake models backed by database views. Declare your view creation/deletion as SeparateDatabaseAndState migrations (with RunSQL operations creating the actual views). It’s not scalable long-term, but if your objective is to either slowly migrate those views to true Django models, or for few, specific tables, then I think it’s a good workaround.
- ehutch79 3y agoIf you’re not all in on the Orem I’m not sure I’d recommend django
- ehutch79 3y agoOn mobile. I meant ORM
- jgalt212 3y agoIf you have a database-driven web app, and you like Python, what would use then?
- ehutch79 3y agoProbably something like flask/sql alchemy. It’s been a bit since I’ve looked at the field. But Django is definitely opinionated on things
- 7373737373 3y agoIf it's a simple app, check out this flask+dataset(sqlite) approach: https://github.com/void4/lazyweb/ https://github.com/void4/lazyweb/
- andybak 3y agoThis doesn't match my experience.
- jgalt212 3y agoso you do your online and offline database operations using the Django ORM?
- andybak 3y agoI'm not sure I understand what you mean by online and offline in this context?
- jgalt212 3y agodo you have CRUD code running on the web app, and offline / batch jobs where both sets of jobs / functions / processes modify the same database that Django wants to ORM and your data scientists and ETL folks don't want to do Django ORM - or ORM at all.
- andybak 3y agoThe original comment was: > The Django ORM is close to useless if your database is not generated by the web app to which I replied > not in my experience I have a legacy database derived from an outside source which is running in production and all my code interacts with it via the Django ORM.
- jgalt212 3y ago> I have a legacy database derived from an outside source which is running in production and all my code interacts with it via the Django ORM. And I'm sure the Django ORM works fine for you if you're only doing read operations and the legacy database schema never migrates.
- andybak 3y ago
- Takennickname 3y agoIncorrect. See here: https://docs.djangoproject.com/en/4.2/howto/legacy-databases/ https://docs.djangoproject.com/en/4.2/howto/legacy-databases...