This is a complete demonstration of pGenie in action, showing how it generates type-safe client libraries from SQL migrations and queries.
demo/
├── project1.pgn.yaml # Project configuration
├── freeze1.pgn.yaml # Autogenerated file with frozen versions of codegens
├── migrations/ # Database schema migrations
├── queries/ # Parameterized SQL queries
└── artifacts/ # Generated code artifacts
├── haskell/
├── java_null/
├── java_optional/
└── rust/
The artifacts/ directory contains generated code that pGenie produces based on your migrations and queries. This directory is the output of running pgn generate.
-
haskell/ - A Haskell library with type-safe mappings
- Integrates with the hasql library
-
java_null/ - A Java library with type-safe mappings using
nullfor nullable types- Integrates with the pgJDBC library
-
java_optional/ - A Java library with type-safe mappings using
Optionalfor nullable types- Integrates with the pgJDBC library
-
rust/ - A Rust library with type-safe mappings
- Integrates with the tokio-postgres library
To see pGenie in action:
-
Delete the artifacts directory:
rm -rf artifacts
-
Delete the freeze file:
rm freeze1.pgn.yaml
-
Delete the signature files:
rm -rf queries/*.sig1.pgn.yaml -
Run the generator:
pgn generate
-
Observe the results:
The artifacts/ directory is recreated with SDKs for all languages inside.
The first time you run pGenie it will take 2-3 minutes while it performs initial setup:
- Docker image caching — Downloads and caches the PostgreSQL Docker image
- Code generator caching — Downloads and caches the Dhall code for the configured generators
You may notice pGenie appears to "hang" on the "Starting Container" and "Loading" stages during this initial setup. This is normal!
After the first run, subsequent executions will complete in just a few seconds.
- Modify a query in
queries/and runpgn generateto see the artifacts update - Add a new migration in
migrations/to evolve your schema - Explore the generated code in
artifacts/to see the type-safe functions