1
0
Fork 0
empact/db/common.go

20 lines
318 B
Go
Raw Normal View History

2015-03-04 19:09:08 +00:00
package db
import (
2015-03-05 16:06:45 +00:00
"strings"
2015-03-04 19:14:11 +00:00
_ "github.com/go-sql-driver/mysql"
2015-03-05 16:06:45 +00:00
"github.com/jmoiron/sqlx"
"github.com/jmoiron/sqlx/reflectx"
2015-03-04 19:09:08 +00:00
)
var (
2015-03-06 10:00:04 +00:00
conn *sqlx.DB
2015-03-04 19:09:08 +00:00
)
2015-03-05 16:06:45 +00:00
func Connect(params string) (err error) {
conn, err = sqlx.Connect("mysql", params)
2015-03-06 10:00:04 +00:00
conn.Mappper = reflectx.NewMapperFunc("json", strings.ToLower)
2015-03-04 19:09:08 +00:00
return
}