4 ms·
One thing I really miss from the JVM world was something like jOOQ. I don't want an ORM (like specifically the object relational mapping stuff) for most of my
by kasey_junk 8y ago
One thing I really miss from the JVM world was something like jOOQ.
I don't want an ORM (like specifically the object relational mapping stuff) for most of my use cases but I do want an abstraction above text for interacting with SQL.
gorm's sql builder is alright but something better would be really nice.
- kodablah 8y agoAgreed. Really, just an open/transparent SQL builder part and an uncoupled row scanner that can populate structs reflectively is the perfect middleground to work around the impedance mismatch that inevitably occurs using these magic ORMs.
- cryptonector 8y agoI don't even want an abstraction for building SQL unless I need to build queries dynamically from some other (presumably simpler) query language. Put all the SQL in .sql files and make all queries parametrized. Or wrap all queries in VIEWs or functions at the RDBMS. This makes maintenance much easier.
- dragonwriter 8y ago> Or wrap all queries in VIEWs or functions at the RDBMS. This is like the oldest best practice for RDBMS use, for security, and for decoupling consuming apps from each other and the DBs low level implementation (so that app views and base tables can evolve independently to the extent possible), and for maintainability: all app access to the DB should be through views adapted to the apps needs.
- cryptonector 8y agoExactly. And it works very well. I recommend PostgREST to export a RESTful interface to a single PG schema's VIEWs and functions, and RLS and INSTEAD OF triggers as needed.
- chatmasta 8y agopsycopg2 is good for this in python.
- luhn 8y agopsycopg2 is a Postgres driver, it is not a query builder like jOOQ. Python's equivalent would be SQLAlchemy Core.
- chatmasta 8y agoI was referring to the string composition [0] of psycopg2, a library which also takes care of converting SQL results to the correct Python data type. IMO that meets the criteria for an "abstraction above text" that GP was asking for. But yes, SQLAlchemy Core is far more full-featured and gives you more than just a few primitives to work with. It also has a lot of library-specific constructs and is much closer to a full-fledged "ORM" than a query builder; what you're writing is not exactly SQL and is yet another dialect to learn. [0] http://initd.org/psycopg/docs/sql.html http://initd.org/psycopg/docs/sql.html
- mceachen 8y agoIf you're using node, try https://knexjs.org/ https://knexjs.org/. The API is very similar.