db.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. _ "github.com/go-sql-driver/mysql"
  5. "hongze/hongze_edb_lib/models/future_good"
  6. "hongze/hongze_edb_lib/utils"
  7. "time"
  8. )
  9. func init() {
  10. _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL)
  11. orm.SetMaxIdleConns("default", 50)
  12. orm.SetMaxOpenConns("default", 100)
  13. db, _ := orm.GetDB("default")
  14. db.SetConnMaxLifetime(10 * time.Minute)
  15. _ = orm.RegisterDataBase("edb", "mysql", utils.MYSQL_URL_EDB)
  16. orm.SetMaxIdleConns("edb", 50)
  17. orm.SetMaxOpenConns("edb", 100)
  18. edb_db, _ := orm.GetDB("edb")
  19. edb_db.SetConnMaxLifetime(10 * time.Minute)
  20. _ = orm.RegisterDataBase("gl", "mysql", utils.MYSQL_URL_GL)
  21. orm.SetMaxIdleConns("gl", 50)
  22. orm.SetMaxOpenConns("gl", 100)
  23. gl, _ := orm.GetDB("gl")
  24. gl.SetConnMaxLifetime(10 * time.Minute)
  25. orm.Debug = true
  26. orm.DebugLog = orm.NewLog(utils.Binlog)
  27. //注册对象
  28. orm.RegisterModel(
  29. new(EdbDataCalculateZjpj),
  30. new(EdbDataCalculateLjztbpj),
  31. new(EdbInfo),
  32. new(EdbInfoCalculateMapping),
  33. new(EdbPythonCode),
  34. new(EdbDataPython),
  35. new(ChartEdbMapping),
  36. new(PredictEdbConf),
  37. new(EdbClassify),
  38. new(PredictEdbConfCalculateMapping),
  39. new(PredictEdbRuleData),
  40. new(EdbDataCalculateNhcc),
  41. new(EdbDataPredictCalculateLjztbpj),
  42. new(EdbDataPredictCalculateNhcc),
  43. new(EdbDataPredictCalculateZjpj),
  44. )
  45. // 注册期货数据 数据表
  46. initFutureGood()
  47. }
  48. // initFutureGood 注册期货数据 数据表
  49. func initFutureGood() {
  50. //注册对象
  51. orm.RegisterModel(
  52. new(future_good.FutureGoodEdbInfo), //期货指标表
  53. new(future_good.FutureGoodEdbData), //期货指标数据表
  54. )
  55. }