SQLBoiler is a tool to generate Go boilerplate code for database interactions. So far this includes struct definitions and database statement helper functions.
If anyone wants to create a driver for their own database it's easy very to do. All you need to do is create a driver in the ````/dbdrivers```` package that implements the ````DBDriver```` interface (you can use ````postgres_driver.go```` as an example), and add your driver to the switch statement in the ````initDBDriver()```` function in ````sqlboiler.go````. That's it!
I've included templates for struct definitions and select, delete and insert statement helpers. Editing the output of the existing templates is as easy as modifying the template file, but to add new types of statements you'll need to add a new command and a new template. This is also very easy to do, and you can use any of the existing command files as an example.
# Why?
Because writing boilerplate is annoying, that's why!
SQLBoiler connects to your database (defined in your config.toml file) to ascertain the structure of your tables, and builds your Go boilerplate code using the templates defined in the ````/templates```` folder.
Running SQLBoiler without the ````--table```` flag will result in SQLBoiler building boilerplate code for every table in your database marked as ````public````.
For example, on a table with the following schema:
You have the ability to generate specific objects, or all objects by using the appropriate command. You can also choose to generate for all tables, a single table, or a group of tables using the ````--table```` flag. By default SQLBoiler outputs to Stdout, unless a file is specified with the ````--out```` flag.
Before you use SQLBoiler make sure you create a ````config.toml```` configuration file with your database details, and specify your database by using the ````--driver```` flag.