Hacker News new | ask | show | jobs
by rollcat 339 days ago
I think the ORM is fine. There's always some friction coming from mapping rows to classes and objects, but you can always drop down a layer and just pull raw tuples.

What I'm not a fan of, is the query DSL. Normally, the developer works to figure out how to express their problem with SQL; then the DB engine works to figure out how to map that SQL to the data it has on disk. Now Django adds another layer, which is completely unlike SQL, has its own unique pitfalls, etc; sometimes I find myself just dumping the raw SQL, working on that to get the result I wanted, then working that back to the DSL.

I think SQLAlchemy gets it right. The query language is a thin veil over SQL, and mapping to objects is an explicit and clear operation. What does feel clunky to me, is setup: SQLAlchemy expects you to bring your own glue; Django is vertically integrated.

2 comments

This is my pain point in Django as well, the query DSL. 10+ years with Django and I still don't know how it's supposed to work, given it's all done within the namespace of a function call.

Fortunately, I now have AI to write any Django queries for me.

There's nothing stopping you from using Django with SQLAlchemy or even raw SQL.