base.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # -*- coding: utf-8 -*-
  2. from sqlalchemy import String, Column, Integer,DateTime,Text,Date,Time,ForeignKey
  3. from database import Base
  4. from sqlalchemy.orm import relationship
  5. from datetime import datetime
  6. class AppInfo(Base):
  7. """
  8. 应用表
  9. """
  10. __tablename__ = "tp_app_info"
  11. app_id = Column(String(100), primary_key=True)
  12. app_secret = Column(String(100))
  13. hashed_secret = Column(String(100))
  14. app_name = Column(String(100))
  15. note = Column(String(100))
  16. def __repr__(self):
  17. return "<AppInfo>{}:{}".format(self.app_id, self.app_secret)
  18. class Config:
  19. orm_mode = True
  20. class ApiServiceEntity(Base):
  21. __tablename__ = "tp_api_service"
  22. id = Column(String(100), primary_key=True)
  23. name = Column(String(100))
  24. status = Column(String(100))
  25. create_time = Column(DateTime, default=datetime.now)
  26. class Config:
  27. orm_mode = True
  28. class DatasourceEntity(Base):
  29. __tablename__ = "tp_datasource"
  30. id = Column(String(100), primary_key=True)
  31. name = Column(String(100))
  32. scope = Column(String(100))
  33. dsn = Column(String(100))
  34. dbtype = Column(String(100))
  35. host = Column(String(100))
  36. user = Column(String(100))
  37. password = Column(String(100))
  38. database = Column(String(100))
  39. port = Column(Integer)
  40. charset = Column(String(100))
  41. class Config:
  42. orm_mode = True
  43. class CommandEntity(Base):
  44. __tablename__ = "tp_command"
  45. id = Column(String(100), primary_key=True)
  46. sqltext = Column(String(100))
  47. datasource = Column(String(100))
  48. scope = Column(String(100))
  49. update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now)
  50. class Config:
  51. orm_mode = True
  52. class OprIdxStat(Base):
  53. """
  54. 指标统计表
  55. 统计各项指标
  56. """
  57. __tablename__ = "opr_idx_stat"
  58. id = Column(Integer, primary_key=True, autoincrement=True, comment='id')
  59. stat_dt = Column(DateTime,comment='统计日期')
  60. stat_lvl = Column(Integer,comment='统计级别 1地市2市有关单位3区县')
  61. area_id = Column(String(100),comment='行政区划编码')
  62. area_nm = Column(String(100),comment='行政区划名称')
  63. index_no = Column(String(100),comment='指标编号')
  64. index_nm = Column(String(100),comment='指标名称')
  65. index_value = Column(String(100),comment='指标度量值')
  66. index_unit = Column(String(100), comment='指标单位')
  67. etl_time = Column(DateTime,comment='etl加工时间戳')
  68. class Config:
  69. orm_mode = True
  70. class OprIdx(Base):
  71. """
  72. 指标表
  73. 存储各项指标,记录统计sql
  74. """
  75. __tablename__ = "opr_idx"
  76. id = Column(Integer, primary_key=True, autoincrement=True, comment='id')
  77. index_no = Column(String(100),comment='指标编号')
  78. index_nm = Column(String(100),comment='指标名称')
  79. index_sql = Column(Text,comment='指标统计sql')
  80. index_corn = Column(String(100), comment='执行指标corn表达式')
  81. create_time = Column(DateTime,comment='创建时间')
  82. class Config:
  83. orm_mode = True