Skip to content

jeromer/sqrible

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Problematic

Sqrible came out of the frustation of working with pgx and sqlx.

I had to buid a crappy bridge which led to nowhere and this did not solve the problem that for every request sqlxhas to use Golang's reflection to map query results to struct fields.

This did not sound right.

The other option is to map each field manually but that's tedious and error prone.

So the solution is to generate go code that would do everything automatically.

The advantages are:

  • I no longer need sqlx and thus limit reflection usage to pgx
  • With a set of template I can generate the code I need and update it easily with a few template changes

How does it work ?

Sqrible scans informations about a given table, reads what you configured for this table in a yaml config file and output the generated code you built with the provided template.

Building

make deps build

Usage

./bin/sqrible --help

Usage of ./bin/sqrible:
  -c string
        /path/to/config/file.yaml
  -d string
        template dir
  -t string
        table name

Examples

Have a look in the examples directory which contains one simple template which showcases informations sqrible has about a table. The advanced example showcases a more real life usage.

Demo

Other projects in this field

FAQ

Do you plan to support other DBMSes ?

No. I only need Postgres support and do not plan to provide any support for MySQL, Oracle ... Have at look at xo ;)

About

Generates Go code that matches your Postgres tables

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published