This commit is contained in:
TsMask committed 2023-08-22 19:25:39 +08:00
1 parent 38d3b7450e
commit 96de169777
45 files changed
+881 -676

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
package db
import (
"omc/conf"
"github.com/aceld/zinx/zlog"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
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
}