go-sql-simple

module
v0.0.0-...-fcf3058 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2023 License: Apache-2.0

README


sql-simple.png logo

go-sql-simple

Go-Sql-simple is an open source sql lib for for making simple sql operation with transaction whilst avoiding boilte plate code and ease development

Installation

go get github.com/chen-keinan/go-sql-simple

Supported DBs:

  • postgresql

Usage


import (
    "context"
    "fmt"
    "github.com/chen-keinan/go-sql-simple/pkg/db"
)

func main() {
    
	connector := db.NewConnector("user", "password", "5432", "db", "host", "postgres")
    driver, err := db.NewPGDriver(connector)
    if err != nil {
        panic(err)
}
    pgMgr := db.NewPostgresqlMgr(driver)
    cbg := db.GetTxContext(context.Background())
    th := db.NewTxHandler(pgMgr)
    res, err := th.ExecuteTx(cbg, "update users set email = ? where name = ? ", "test@gmail.com", "david")
    if err != nil {
        panic(err)
    }
    th.Commit(cbg)
    fmt.Println(res)
}

Directories

Path Synopsis
pkg
db

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL