4 ms·
You can use raw sql in django where it matters and let the ORM handle standard CRUD operations (https://docs.djangoproject.com/en/4.0/topics/db/sql/ https://doc
by m_ke 5y ago
You can use raw sql in django where it matters and let the ORM handle standard CRUD operations (https://docs.djangoproject.com/en/4.0/topics/db/sql/ https://docs.djangoproject.com/en/4.0/topics/db/sql/). I usually start with the ORM and if I need to do something complex or if there's a slow query I just rewrite it in SQL when it becomes an issue.
Also if you'd like to manage the tables with SQL there's an easy way to generate the models from the database schema (https://docs.djangoproject.com/en/3.2/howto/legacy-databases/ https://docs.djangoproject.com/en/3.2/howto/legacy-databases...). I've used it before at a startup to migrate from hand coded schemas and migrations in SQL that only one person was brave enough to touch (they had no way to run things locally) to a full consistent REST API for like 20 tables ready in 2 days.
I'm also managing an SQLite db on a mobile app that uses hand written SQL (with 20ish tables and a few 100 queries) and any changes to the database end up being a nightmare of manually editing raw strings.