| 7 | from .database import Base |
| 8 | |
| 9 | class Audio(Base): |
| 10 | __tablename__ = 'audio' # 数据表的表名 |
| 11 | |
| 12 | id = Column(Integer, primary_key=True, index=True, autoincrement=True) |
| 13 | title = Column(String(100), unique=True, nullable=False, comment='音频名称') |
| 14 | size = Column(String(100), comment='文件大小') |
| 15 | extension = Column(String(100), comment='文件类型') |
| 16 | progress = Column(Float, default=False, comment='进度') |
| 17 | data = relationship('Data', back_populates='audio') # 'Data'是关联的类名;back_populates来指定反向访问的属性名称 |
| 18 | created_at = Column(DateTime, server_default=func.now(), comment='创建时间') |
| 19 | |
| 20 | # __mapper_args__ = {"order_by": created_at} # 默认是正序,倒序加上.desc()方法 |
| 21 | |
| 22 | #读取数据后,显示出来的方式 |
| 23 | def __repr__(self): |
| 24 | return f'{self.title}_{self.size}' |
| 25 | |
| 26 | |
| 27 | class Data(Base): |
nothing calls this directly
no outgoing calls
no test coverage detected