ANN: pGenie – a SQL-first code generator for PostgreSQL: no DSLs, no ORMs, no hand-rolled codecs
Hello colleagues,
I’m Nikita Volkov, the author of “hasql”. After “hasql-th” brought compile-time SQL syntax checking a few years back, one significant gap remained: the validation of query compatibility with the actual database schema. Another concern coming from users has long been the need to hand-roll encoders and decoders for every query.
Today I’m releasing pGenie - a tool that completely rethinks the way we integrate with Postgres from Haskell and it addresses these pain points and so much more!
What it does
You give pGenie two things:
Your SQL migration files (plain
CREATE TABLE …,ALTER …, etc.)Your SQL query files (plain
SELECT …,INSERT …, etc.)
It executes them against real PostgreSQL via a Docker container, validates queries against your schema, and generates a fully type-safe Haskell SDK on top of “hasql”. There is no DSL to learn, no Template Haskell, no ORM layer. Postgres itself is the single source of truth.
Besides Haskell it also generates Rust and actually has a decentralized codegen ecosystem that allows you to write your own codegens in beautiful Dhall and distribute them however you like.
As the cherry on top, pGenie also automates index management to some extent.
Links
Landing page: pgenie.io
Docs and quickstart: pgenie.io/docs
Demo: github.com/pgenie-io/demo
Source: github.com/pgenie-io/pgenie
pGenie is free and open source. I’d be grateful for feedback, bug reports, and a GitHub star if you find it useful!
Discussion in the ATmosphere