db.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. new(EdbDataInsertConfig),
  45. )
  46. // 注册期货数据 数据表
  47. initFutureGood()
  48. }
  49. // initFutureGood 注册期货数据 数据表
  50. func initFutureGood() {
  51. //注册对象
  52. orm.RegisterModel(
  53. new(future_good.FutureGoodEdbInfo), //期货指标表
  54. new(future_good.FutureGoodEdbData), //期货指标数据表
  55. )
  56. }