SQL query builder for Go. Might also be used as an extension for Squirrel.
Go to file
Reinaldy Rafli 03e6bdb7fc fix: replacePlaceholder now do things properly
test: added more tests
2021-06-26 09:57:08 +07:00
.github fix: replacePlaceholder now do things properly 2021-06-26 09:57:08 +07:00
util fix: replacePlaceholder now do things properly 2021-06-26 09:57:08 +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 fix: replacePlaceholder now do things properly 2021-06-26 09:57:08 +07:00
append.go fix: replacePlaceholder now do things properly 2021-06-26 09:57:08 +07:00
bob.go fix: replacePlaceholder now do things properly 2021-06-26 09:57:08 +07:00
create.go fix: replacePlaceholder now do things properly 2021-06-26 09:57:08 +07:00
create_test.go fix: replacePlaceholder now do things properly 2021-06-26 09:57:08 +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 fix: replacePlaceholder now do things properly 2021-06-26 09:57:08 +07:00
has_test.go fix: replacePlaceholder now do things properly 2021-06-26 09:57:08 +07:00
placeholder.go fix: replacePlaceholder now do things properly 2021-06-26 09:57:08 +07:00
placeholder_test.go fix: replacePlaceholder now do things properly 2021-06-26 09:57:08 +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
}