~/talk

No More Raw SQL: SQLAlchemy & ORMs

Talkat PyData London 2024 Β· 2024-06-14..06-16Β· [databases, developer-experience]
links:none on file
slides:none on file

A Marketplace microservice with five tables (customers, addresses, orders, order_items, items) moves from raw sqlite3 SQL to SQLAlchemy core and then declarative ORM models; multi-join queries become a two-line select, inserts become session.add + session.commit, and migrations use alembic. The demo logs SQL via echo, contrasts connection.commit vs engine.begin, exposes the N+1 problem (loading three customers issues four queries and would blow up with hundreds or thousands), and shows eager loading and func.sum optimisations that actually reduce queries and commit successfully.

AI-written summary Β· about

  1. 0:00SQLAlchemy & ORMs intro
  2. 1:04From raw SQL to core
  3. 7:07Sample microservice
  4. 8:56Raw SQL queries
  5. 11:07SQLAlchemy engine
  6. 12:54SELECT with SQLAlchemy
  7. 14:42Committing data
  8. 16:30Adding ORMs
  9. 19:17Tables to Python classes
  10. 21:03Querying data with ORMs
  11. 23:50Complex ORM queries
  12. 24:33Inserting with ORMs
  13. 27:00Lazy loading
  14. 29:04N+1 problem fix
  15. 30:09SQL functions
  16. 30:53Summary
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark β€” the status bar button does the same
?
this help
esc
close this, then clear every filter β€” or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.