db.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package models
  2. import (
  3. "eta/eta_crawler/utils"
  4. "time"
  5. _ "github.com/go-sql-driver/mysql"
  6. "github.com/beego/beego/v2/client/orm"
  7. )
  8. func init() {
  9. if utils.BusinessCode == utils.BusinessCodeRelease {
  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("data", "mysql", utils.MYSQL_URL_DATA)
  16. orm.SetMaxIdleConns("data", 50)
  17. orm.SetMaxOpenConns("data", 100)
  18. data_db, _ := orm.GetDB("data")
  19. data_db.SetConnMaxLifetime(10 * time.Minute)
  20. }
  21. orm.Debug = true
  22. orm.DebugLog = orm.NewLog(utils.Binlog)
  23. //注册对象
  24. orm.RegisterModel(
  25. new(BaseFromTradeZhengzhouIndex),
  26. new(BaseFromTradeShanghaiIndex),
  27. new(BaseFromTradeIneIndex),
  28. new(BaseFromTradeCffexIndex),
  29. new(BaseFromTradeEicIndex),
  30. new(BaseFromTradeEicIndexV2),
  31. new(BaseFromTradeMapping),
  32. new(BaseFromChangesVisitorsCovid),
  33. new(BaseFromTradeDalianIndex),
  34. new(BaseFromCoalmineMapping),
  35. new(BaseFromCoalmineJsmIndex),
  36. new(BaseFromCoalmineCompanyIndex),
  37. new(BaseFromCoalmineFirmIndex),
  38. new(BaseFromCoalmineCoastalIndex),
  39. new(BaseFromCoalmineInlandIndex),
  40. //new(BaseFromTradeDalianData),
  41. new(BaseFromEiaSteoIndex),
  42. new(BaseFromEiaSteoData),
  43. new(BaseFromEiaSteoClassify),
  44. new(ComTradeCountry),
  45. new(ComTradeData),
  46. new(ComTradeCodeMapping),
  47. new(BaseFromNationalStatisticsClassify),
  48. new(BaseFromNationalStatisticsIndex),
  49. new(BaseFromNationalStatisticsData),
  50. new(MeetingProbabilities),
  51. new(BaseFromIcpiIndex),
  52. new(BaseFromIcpiData),
  53. ////广期
  54. new(BaseFromTradeGuangzhouClassify),
  55. new(BaseFromTradeGuangzhouIndex),
  56. new(BaseFromTradeGuangzhouData),
  57. new(BaseFromTradeGuangzhouContract),
  58. new(BaseFromIcpiClassify),
  59. new(BaseFromSci99Index),
  60. new(BaseFromSci99Data),
  61. new(BaseFromSci99Classify),
  62. )
  63. }