SQL query builder for Go. Might also be used as an extension for Squirrel.
Go to file
Reinaldy Rafli 5c112c73f6 feat: added has query 2021-06-26 00:04:41 +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 docs: added badges :) 2021-06-25 14:32:12 +07:00
append.go feat: added has query 2021-06-26 00:04:41 +07:00
bob.go feat: added has query 2021-06-26 00:04:41 +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: added has query 2021-06-26 00:04:41 +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: added has query 2021-06-26 00:04:41 +07:00
has_test.go feat: added has query 2021-06-26 00:04:41 +07:00
placeholder.go feat: added has query 2021-06-26 00:04:41 +07:00

README.md

Bob - SQL Query Builder

Go Reference Go Report Card GitHub CodeFactor codecov Codacy Badge Build test Test and coverage

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
}