同步代码
This commit is contained in:
24
db/mysql.go
Normal file
24
db/mysql.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"github.com/aceld/zinx/zlog"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"omc/conf"
|
||||
)
|
||||
|
||||
var Client *gorm.DB
|
||||
|
||||
func Init() error {
|
||||
|
||||
d, err := gorm.Open(mysql.Open(conf.OmcConf.Mysql), &gorm.Config{})
|
||||
if err != nil {
|
||||
zlog.Ins().ErrorF("open mysql %s error, ", conf.OmcConf.Mysql, err)
|
||||
panic(err)
|
||||
}
|
||||
sqlDB, _ := d.DB()
|
||||
sqlDB.SetMaxOpenConns(20)
|
||||
sqlDB.SetMaxIdleConns(10)
|
||||
Client = d
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user