sqlgen2

sqlgen generates SQL statements from your Go structs, used along with
sqlapi database helper functions. It takes the
place of a simple ORM or hand-written SQL.
See the demo directory for examples. Look in the
generated files *_sql.go
and the hand-crafted files (hook.go
, issue.go
, user.go
).
Features
- Auto-generates DAO-style table-support code for SQL databases.
- Sophisticated parsing of a Go
struct
that describes records in the table.
- Allows nesting of structs, fields that are structs or pointers to structs etc.
- Struct tags give fine control over the semantics of each field.
- Supports indexes and constraints.
- Supports foreign key relationships between tables.
- Helps you develop code for joins and views.
- Supports JSON-encoded columns, allowing a more no-SQL model when needed.
- Provides a builder-style API for constructing where-clauses and query constraints.
- Allows declarative requirements on the expected result of each query, enhancing error checking.
- Very flexible configuration.
- Fast and easy to use.
Currently, support is included for MySQL, PostgreSQL and SQLite. Other dialects can be added relatively easy - send a Pull Request!
Install
-- this is being revised --
Usage
See the command line usage.
Tutorial
See the tutorial.
Credits
This tool was derived from sqlgen by drone.io, which was itself
inspired by scaneo.