2022-09-20 15:50:01 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
2022-11-09 06:20:26 +00:00
|
|
|
. "battle_srv/common"
|
2022-09-20 15:50:01 +00:00
|
|
|
|
|
|
|
_ "github.com/go-sql-driver/mysql"
|
|
|
|
"github.com/jmoiron/sqlx"
|
|
|
|
"go.uber.org/zap"
|
2022-10-14 08:08:22 +00:00
|
|
|
|
|
|
|
. "dnmshared"
|
2022-09-20 15:50:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
MySQLManagerIns *sqlx.DB
|
|
|
|
)
|
|
|
|
|
|
|
|
func initMySQL() {
|
|
|
|
var err error
|
|
|
|
MySQLManagerIns, err = sqlx.Connect("mysql", Conf.MySQL.DSN+"?charset=utf8mb4")
|
2022-10-14 08:08:22 +00:00
|
|
|
if nil != err {
|
|
|
|
panic(err)
|
|
|
|
}
|
2022-09-20 15:50:01 +00:00
|
|
|
err = MySQLManagerIns.Ping()
|
2022-10-14 08:08:22 +00:00
|
|
|
if nil != err {
|
|
|
|
panic(err)
|
|
|
|
}
|
2022-09-20 15:50:01 +00:00
|
|
|
Logger.Info("MySQLManagerIns", zap.Any("mysql", MySQLManagerIns))
|
|
|
|
}
|