Leave Your Inhibitions at the Database Connection
summary
A migration from hand‑written SQL toward the Django ORM shows concrete wins: raw queries using a raw SQL cursor with fetchall tuples require manual rehydration (namedtuple) and invite SQL‑injection risk, while ORM features like select_related, annotate + Prefetch reduce code, keep results as model objects, and avoid reshaping rows. Examples include LaMetro Councilmatic (committee memberships and custom ordering implemented with a Case ordering via annotation) and a Coordinated Entry report where ORM aggregation replaces a verbose join and extra data transformation, and the ORM solutions perform and read far better.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 2:53Overview
- 8:50LA Metro CouncilMatic
- 13:42Comfort
- 14:32Why the ORM
- 15:02Django Docs
- 16:07Alert Box Warning
- 16:52Data Types
- 19:17Data Rich Iterables
- 20:57Coordinated Entry Screaming
- 27:02Takeaways
- 28:12Conclusion
related talks
01h 04mInside the ORM
37mNo More Raw SQL with SQLAlchemy and ORMs
21mCustom Model Managers and QuerySets: Graduating from Django Beginner to ORM Master
32mNo More Raw SQL: SQLAlchemy & ORMs
52mThe SQL inside the ORM/Builder box | Claudio Zizza
59mHow much database abstraction do I need?
16mBig O No: Django ORM runtime complexity and how to avoid it using LATERAL JOINS
29mMaking smarter queries with advanced ORM resources
