Skip to content

lramosduarte/god-sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

god-sql is a really simple sql builder and nothing more!

Disclaimer: this repository was created sometime in the past from scratch for me to learn a little about golang. Now I decided to push and maybe improve and/or finish some things.

Features

  • SQL Builder
  • Separeted builder Select(DQL) statement available
    • predicate(where clause) builder
    • Select columns builder only
  • compatibilty with sql ansi-92
  • [] DML Builder
  • [] Building query(returned columns or predicates) from maps, struct or slice

What ins't expected to be done

  • Parameter interpolation

Builder

Select:

import github.com/lramosduarte/god-sql/builder

...
    sql := builder.Builder{}.Select().From("foo_bar").Build()
...

output:

SELECT * FROM foo_bar

Select With filters:

import github.com/lramosduarte/god-sql/builder

...
    ps := predicate.Predicates{}
    ps.And("c1", predicate.Equal, "$1").And("c2", predicate.Greater, "$2")
    sql := builder.Builder{}.Select().From("foo_bar").Where(ps).Build()
...

output:

SELECT * FROM foo_bar WHERE c1 = $1 AND c2 > $2

Select specified columns:

import github.com/lramosduarte/god-sql/builder

...
    sql := builder.Builder{}.Select("foo", "bar").From("foo_bar").Where().Build()
...

output:

SELECT foo, bar FROM foo_bar WHERE c1 = $1 AND c2 > $2

More samples in test files.

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages