knowledge_base.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from sqlalchemy import create_engine, Column, Integer, String, ForeignKey, DateTime, Table, MetaData,Text
  2. from sqlalchemy.ext.declarative import declarative_base
  3. from sqlalchemy.orm import relationship, sessionmaker
  4. Base = declarative_base()
  5. metadata = MetaData()
  6. from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey
  7. from sqlalchemy.orm import relationship
  8. class KnowledgeFile(Base):
  9. __tablename__ = 'knowledge_file'
  10. id = Column(Integer, primary_key=True, autoincrement=True, comment="id")
  11. file_identifier = Column(String(50), unique=True, nullable=False, comment='文件唯一标识符')
  12. file_path = Column(Text, nullable=False, comment='文件路径')
  13. file_name = Column(String(255), nullable=False, comment='文件名字')
  14. is_deleted = Column(Integer, default=0, comment='是否删除')
  15. createTime = Column(DateTime, comment='创建时间')
  16. updateTime = Column(DateTime, comment='更新时间')
  17. storage_file_name = Column(Text,comment = '文件存储名字')
  18. knowledge_base_code = Column(String(50), ForeignKey('knowledge_base.base_code'), nullable=False)
  19. knowledge_base = relationship("KnowledgeBase", back_populates="files")
  20. class KnowledgeBase(Base):
  21. __tablename__ = 'knowledge_base'
  22. id = Column(Integer, primary_key=True, autoincrement=True, comment="id")
  23. reportId = Column(String(255),comment='报告ID')
  24. reportUid = Column(String(255),comment='报告UUID')
  25. reportName = Column(String(400), comment='报告名称')
  26. subject = Column(String(100), comment='主题词')
  27. eventType = Column(String(10), comment='事件类型')
  28. publishDate = Column(DateTime, comment='发布日期')
  29. publishingUnit = Column(String(255), comment='来源单位')
  30. summary = Column(String(100), comment='摘要')
  31. notificationType = Column(String(100), comment='知识类型')
  32. updateTime = Column(DateTime, comment='更新时间')
  33. base_code = Column(String(50), unique=True, comment='知识库的基础编码')
  34. del_flag = Column(String(10), comment='是否删除')
  35. files = relationship("KnowledgeFile", order_by=KnowledgeFile.id, back_populates="knowledge_base")