SQL query builder for Go. Might also be used as an extension for Squirrel.
Go to file
Reinaldy Rafli 6c36822ecc feat(error): error on empty table name; error on missing primary and unique key in columns; 2021-06-24 15:15:36 +07:00
.github ci: typo on workflow -> workflows 2021-06-24 14:44:43 +07:00
util feat: initial 2021-06-24 14:43:28 +07:00
.gitignore feat: initial 2021-06-24 14:43:28 +07:00
LICENSE feat: initial 2021-06-24 14:43:28 +07:00
README.md feat: initial 2021-06-24 14:43:28 +07:00
append.go feat: initial 2021-06-24 14:43:28 +07:00
bob.go feat: initial 2021-06-24 14:43:28 +07:00
create.go feat(error): error on empty table name; error on missing primary and unique key in columns; 2021-06-24 15:15:36 +07:00
create_test.go feat: initial 2021-06-24 14:43:28 +07:00
go.mod feat: initial 2021-06-24 14:43:28 +07:00
go.sum feat: initial 2021-06-24 14:43:28 +07:00
has.go feat: initial 2021-06-24 14:43:28 +07:00
placeholder.go feat: initial 2021-06-24 14:43:28 +07:00

README.md

Bob - SQL Query Builder

I really need a create table SQL builder, and I can't find one. So, like everything else, I made one. Heavily inspired by Squirrel and Knex.

Oh, and of course, heavily inspired by Bob the Builder.

Usage

It's not ready for production (yet). But, the API is probably close to how you'd do things on Squirrel.

import "github.com/aldy505/bob"

func main() {
  sql, _, err := bob.CreateTable("users").
    Columns("id", "email", "name", "password", "date").
    Types("varchar(36)", "varchar(255)", "varchar(255)", "text", "date").
    Primary("id").
    Unique("email")
    ToSql()
  if err != nil {
    log.Fatal(err)
  }

  // process SQL with whatever you like it
}