Skip to content

DropFan/go-sqlbuilder

Repository files navigation

go-sqlbuilder

Build Status Go Report Card Coverage Status MIT licensed

(unfinished) a very simple sql builder for golang.

TODO

  • dialect support for mysql/postgresql/sqlite etc... Only support mysql now. (escape character and placeholder were hard coded)

    • (done) escape character (mysql:`) (postgres:") [✔️]
    • placeholder for params binding (mysql:?) (postgres:$index)
    • etc...
  • more statement support (group/having/join etc...)

  • more examples (you could find some examples in test file now)

  • more helpful usages

  • Long-term planning:

    Maybe this package could be a micro ORM?Or add a simple scanner or DAO adapter?

    I have already done a veeeeeery simple and crude demo but it's too simple.

    In general, I hope this package as simple as possible. Waiting for above unitl I have enough free time (long after...).

Installation

go get -u github.com/DropFan/go-sqlbuilder

Usage (unfinished)

// TODO

Click here to get examples.

import (
    builder "github.com/DropFan/go-sqlbuilder"
)

var (
    b = builder.New()
    q *Query
)

b.Select(fields...).
    From("user").
    Where(ageGT1, nameInNames).
    And(sexEqFemale).
    And().
    Or(ageBetweenCond).
    Or(nameEqCoder).
    OrderBy(ageDesc, nameAsc).
    Limit(0, 100)
q, err = b.Build()

Contacts

Author: Tiger(DropFan)

Email: [email protected]

Wechat: DropFan

Telegram: DropFan

https://about.me/DropFan

License

MIT

About

a very simple sql builder for golang. (unfinished)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages