Skip to main content

Bob Gen for SQL

Generates an ORM based on SQL schema files


# With env variable
SQL_DIALECT=psql go run

# With configuration file
go run -c ./config/bobgen.yaml

Driver Configuration

The configuration for the sql driver must be prefixed by the driver name. You must use a configuration file or environment variables for configuring the database driver.

In the configuration file for sql for example you would do:

dialect: psql

When you use an environment variable it must also be prefixed by the driver name:


The values that exist for the drivers:

dialectDatabase dialect to use (REQUIRED)
dirPath to directory containing schema files.
schemasThe database schemas to generate models forpublic (psql dialect), main (sqlite dialect)
shared_schemaSchema to not include prefix in modelfirst schema found
outputFolder for generated files"models"
pkgnamePackage name for generated code"models"
uuid_pkgUUID package to use (gofrs or google)"gofrs"
onlyOnly generate these
exceptSkip generation for these

Example of Only/Except:

# Removes public.migrations table, the name column from the addresses table, and
# secret_col of any table from being generated. Foreign keys that reference tables
# or columns that are no longer generated may cause problems.
- name
- secret_col