Hacker News new | ask | show | jobs
by anta40 470 days ago
What would you use if ORM is to be avoided?

Perhaps something like https://github.com/sqlc-dev/sqlc ?

3 comments

My advice is to just use standard library `database/sql`. Every abstraction on top adds extra complexity and isn't really necessary. Just execute a query, map the results, and there you go.
"Every abstraction on top adds extra complexity and isn't really necessary"

This. In my experience, every project that has non-trivial query requirements starts out as "this ORM is nice, it takes away 90% of my work" and ends with "how do I get rid of that leaky abstraction layer that constantly makes my life harder."

I'm using this at the moment : https://jmoiron.github.io/sqlx/

Didnt' now about sqlc, it seems very interesting ! Thanks for sharing !

Seconding sqlx, it's wonderful, is not an ORM and doesn't need code gen.
sqlc is _excellent_ if you are comfortable with its limitations. I love it even though I don't love optional fields query pattern with NULL.
I would say: SQL is a DSL for interacting with DBs. If it's not doing what you want, consider a different DSL, like Gel, SurrealDB, or PRQL.

These also have the advantage of being programming language-agnostic.