|
|
|
Ask HN: Is it reasonable to choose direct SQL over an ORM
|
|
7 points
by thymanl23
2645 days ago
|
|
I've been using an ORM for years - and often still find myself frustrated trying to map the complexity and nuance of SQL to an ORM api. What is attractive to me about ORMs, though, is the marshaling of raw result rows into predefined structured objects (preferable pure objects). It seems like if I missed this, I could always reach for something like https://github.com/craigmichaelmartin/sql-toolkit - a small library atop database drivers which accepts raw SQL and return back pure, properly nested business objects. Is this reasonable? |
|
I'm working on a project now, the api is graphql using Graphene in Python (flask-graphql with graphiql support), so we basically define the models using that. The graphene resolvers talk to a package called "services" which is where all the business logic and queries live, and services talks to another package "db" which deals with taking sql+params and returning dict rows.
It is exceedingly simple, easy to debug, and we're using postgres, so if you have a sensible schema, postgres can do just about anything you want to do very easily. We're using postgis, and postgres search features under the hood.