4 ms·
I like to go in the other direction: Write the raw SQL and then generate the boilerplate from that. This has very few surprises because it’s a bottom up appro
by dgb23 3y ago
I like to go in the other direction:
Write the raw SQL and then generate the boilerplate from that.
This has very few surprises because it’s a bottom up approach. And even better: you can do the exact same thing by hand.
There’s tools/libs that help with that like hugsql (Clojure) or sqlc (Go and other languages).
Doing it top down (ORM etc.) is what can cause so many problems outside of the happy path and trivial cases. These tools basically need to reinvent SQL and map it into a procedural language.
Just use SQL!
- dkarl 3y agoThere's a tool called PugSQL that looks promising for Python, but it seems that async isn't directly supported yet[0]. If I ever find time, I'd love to jump on this and make it work, but nobody should hold their breath for that. [0] https://github.com/mcfunley/pugsql/issues/44 https://github.com/mcfunley/pugsql/issues/44
- actionfromafar 3y agoQuery builders are a good golden path for me. Just SQL but extra hand holding in type coercion and syntax.
- dkarl 3y agoI think query builders can be very helpful in a language with a good type system. The only times I haven't used raw SQL and didn't feel like it was a massive mistake were when using Scala, via Slick and Quill.