1
0
Fork 0
empact/db/common.go

20 lines
317 B
Go

package db
import (
"strings"
_ "github.com/go-sql-driver/mysql"
"github.com/jmoiron/sqlx"
"github.com/jmoiron/sqlx/reflectx"
)
var (
conn *sqlx.DB
)
func Connect(params string) (err error) {
conn, err = sqlx.Connect("mysql", params)
conn.Mapper = reflectx.NewMapperFunc("json", strings.ToLower)
return
}