Skip to content

nilorg/sqlxplus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sqlxplus

golang sqlx wrap logger

Usage

go get github.com/nilorg/sqlxplus

Import

import "github.com/nilorg/sqlxplus"

Example

import (
    "github.com/jmoiron/sqlx"
    "github.com/nilorg/sqlxplus"
)

func main() {
	driverName := "mysql"
	dataSourceName := "xxx"
	xdb, err := sqlx.Connect(driverName, dataSourceName)
	if err != nil {
		log.Fatalln(err)
	}
	xdbpuls := &sqlxplus.DB{SqlxTx: xdb, Log: &StdLogger{}}
    var result map[string]interface{}
    err = sqlx.GetContext(ctx, xdbpuls.DB(), &result, "select * from user where id = ?", 1)
    if err != nil {
		log.Fatalln(err)
	}
}

Releases

No releases published

Packages

No packages published

Languages