from sqlalchemy.orm import declarative_base from sqlalchemy import Column, Integer, String, Float, UniqueConstraint class PtWebsiteData(declarative_base()): __tablename__ = 'pt_website_data' id = Column(Integer, primary_key=True, autoincrement=True) # pt资源id pt_id = Column(Integer, nullable=False) # 来源名称 source_name = Column(String, nullable=False) # 一级标题 first_title = Column(String, nullable=False) # 二级标题 second_title = Column(String) # 分类id type_id = Column(Integer) # 分类名称 type_name = Column(String) # 种子状态 seed_status = Column(String) # 状态剩余时间 status_remaining_time = Column(String) # 做种状态 seeding_status = Column(String) # 评论数 comment_count = Column(Integer) # 资源上传时间 upload_time = Column(String) # 资源大小 size = Column(String) # 做种数 seed_count = Column(Integer) # 下载数 download_count = Column(Integer) # 完成数 completion_count = Column(Integer) # 发布者 publisher = Column(String) # 豆瓣评分 douban_rating = Column(Float) # IMDB评分 imdb_rating = Column(Float) # 下载链接 download_link = Column(String) # 详情链接 details_link = Column(String) # 定义唯一约束 __table_args__ = ( UniqueConstraint('pt_id', 'source_name', name='uq_pt_id_source_name'), UniqueConstraint('source_name', 'first_title', 'second_title', name='uq_source_titles'), )