db.go 1001 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package models
  2. import (
  3. _ "github.com/go-sql-driver/mysql"
  4. )
  5. func init() {
  6. /**
  7. // eta_report
  8. _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL)
  9. orm.SetMaxIdleConns("default", 50)
  10. orm.SetMaxOpenConns("default", 100)
  11. db, _ := orm.GetDB("default")
  12. db.SetConnMaxLifetime(10 * time.Minute)
  13. // eta_master
  14. _ = orm.RegisterDataBase("eta", "mysql", utils.MYSQL_URL_ETA)
  15. orm.SetMaxIdleConns("eta", 50)
  16. orm.SetMaxOpenConns("eta", 100)
  17. etaDb, _ := orm.GetDB("eta")
  18. etaDb.SetConnMaxLifetime(10 * time.Minute)
  19. // crm_master
  20. if utils.MYSQL_WEEKLY_URL != `` && utils.BusinessCode == utils.BusinessCodeRelease {
  21. _ = orm.RegisterDataBase("weekly", "mysql", utils.MYSQL_WEEKLY_URL)
  22. orm.SetMaxIdleConns("weekly", 50)
  23. orm.SetMaxOpenConns("weekly", 100)
  24. weeklyDb, _ := orm.GetDB("weekly")
  25. weeklyDb.SetConnMaxLifetime(10 * time.Minute)
  26. }
  27. orm.Debug = true
  28. orm.DebugLog = orm.NewLog(utils.Binlog)
  29. //注册对象
  30. orm.RegisterModel(
  31. new(Report),
  32. new(SmartReport),
  33. )
  34. */
  35. }