package models import ( "eta/eta_data_push/utils" "github.com/beego/beego/v2/client/orm" _ "github.com/go-sql-driver/mysql" "time" ) func init() { _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL) orm.SetMaxIdleConns("default", 50) orm.SetMaxOpenConns("default", 100) db, _ := orm.GetDB("default") db.SetConnMaxLifetime(10 * time.Minute) // 用户主库 _ = orm.RegisterDataBase("weekly", "mysql", utils.MYSQL_WEEKLY_URL) orm.SetMaxIdleConns("weekly", 50) orm.SetMaxOpenConns("weekly", 100) weeklyDb, _ := orm.GetDB("weekly") weeklyDb.SetConnMaxLifetime(10 * time.Minute) orm.Debug = true orm.DebugLog = orm.NewLog(utils.Binlog) //注册对象 orm.RegisterModel() }