2016-02-24 11:45:09 +01:00
# SQLBoiler
2016-02-23 09:27:32 +01:00
2016-08-15 17:48:37 +02:00
[![License ](https://img.shields.io/badge/license-BSD-blue.svg )](https://github.com/vattle/sqlboiler/blob/master/LICENSE)
2016-02-25 01:16:02 +01:00
[![GoDoc ](https://godoc.org/github.com/pobri19/sqlboiler?status.svg )](https://godoc.org/github.com/pobri19/sqlboiler)
2016-08-09 09:59:30 +02:00
[![CircleCI ](https://circleci.com/gh/vattle/sqlboiler.svg?style=shield )](https://circleci.com/gh/vattle/sqlboiler)
[![Go Report Card ](https://goreportcard.com/badge/kubernetes/helm )](http://goreportcard.com/report/vattle/sqlboiler)
2016-02-25 01:16:02 +01:00
2016-04-26 13:31:00 +02:00
SQLBoiler is a tool to generate a Go ORM tailored to your database schema.
2016-02-24 11:45:09 +01:00
2016-07-11 07:43:59 +02:00
#### Config
2016-02-25 01:20:39 +01:00
2016-08-15 15:37:41 +02:00
Before you use SQLBoiler make sure you create a `sqlboiler.toml` configuration file containing your database details.
2016-02-25 01:20:39 +01:00
2016-08-15 15:37:41 +02:00
The configuration file loader checks the working directory, `$HOME/sqlboiler/.config` directory and `$XDG_CONFIG_HOME/sqlboiler` directory to locate your configuration file. The working directory takes precedence.
`sqlboiler.toml` example file:
```
2016-02-25 01:20:39 +01:00
[postgres]
host="localhost"
port=5432
user="dbusername"
pass="dbpassword"
dbname="dbname"
2016-08-15 15:37:41 +02:00
sslmode="require"
```
The following config fields are optional, and default to:
```
postgres.port=5432
postgres.sslmode="require"
```
To disable SSLMode, use `sslmode="disable"` .
2016-02-25 01:20:39 +01:00
2016-07-11 07:43:59 +02:00
#### How
2016-02-24 11:45:09 +01:00
2016-08-15 15:37:41 +02:00
SQLBoiler connects to your database (defined in your sqlboiler.toml file) to ascertain the structure of your tables, and builds your Go ORM code using the templates defined in the `/templates` and `/templates_test` folders.
2016-02-24 11:45:09 +01:00
2016-08-15 15:37:41 +02:00
Running SQLBoiler without the `--table` flag will result in SQLBoiler building boilerplate code for every table in your database the `public` schema. Tables created in Postgres will default to the `public` schema.
2016-02-24 11:45:09 +01:00
````
2016-04-26 13:31:00 +02:00
Usage:
2016-08-15 15:37:41 +02:00
sqlboiler [flags] < driver >
Examples:
sqlboiler postgres
2016-02-24 11:45:09 +01:00
Flags:
2016-08-15 15:37:41 +02:00
-o, --output string The name of the folder to output to (default "models")
-p, --pkgname string The name you wish to assign to your generated package (default "models")
2016-02-24 11:45:09 +01:00
````