Skip to content

pgenie-io/demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pGenie Demo Project

This is a complete demonstration of pGenie in action, showing how it generates type-safe client libraries from SQL migrations and queries.

Project Structure

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

The artifacts/ directory contains generated code that pGenie produces based on your migrations and queries. This directory is the output of running pgn generate.

What's Inside

  • haskell/ - A Haskell library with type-safe mappings

    • Integrates with the hasql library
  • java_null/ - A Java library with type-safe mappings using null for nullable types

    • Integrates with the pgJDBC library
  • java_optional/ - A Java library with type-safe mappings using Optional for nullable types

    • Integrates with the pgJDBC library
  • rust/ - A Rust library with type-safe mappings

Try It Yourself

To see pGenie in action:

  1. Delete the artifacts directory:

    rm -rf artifacts
  2. Delete the freeze file:

    rm freeze1.pgn.yaml
  3. Delete the signature files:

    rm -rf queries/*.sig1.pgn.yaml
  4. Run the generator:

    pgn generate
  5. Observe the results:

The artifacts/ directory is recreated with SDKs for all languages inside.

Important: First Run Notice

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.

Next Steps

  • Modify a query in queries/ and run pgn generate to 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

About

Demonstration of pgenie

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages