db.go 424 B

12345678910111213141516171819202122
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. _ "github.com/go-sql-driver/mysql"
  5. "hongze/hongze_robot/utils"
  6. "time"
  7. )
  8. func init() {
  9. _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL)
  10. orm.SetMaxIdleConns("default", 50)
  11. orm.SetMaxOpenConns("default", 100)
  12. db, _ := orm.GetDB("default")
  13. db.SetConnMaxLifetime(10 * time.Minute)
  14. //注册对象
  15. orm.RegisterModel(
  16. new(SmsRecord),
  17. )
  18. }