from sqlalchemy import Column, Date, Integer, String, text from base import db class Railway(db.Model): __tablename__ = 'faker_railway' id = Column(Integer, primary_key=True) name = Column(String(10), nullable=False, server_default=text("''"), comment='乘客姓名') identification = Column(String(18), nullable=False, server_default=text("''"), comment='乘客身份证号码') phone = Column(String(20), nullable=False, server_default=text("''"), comment='手机号码') train = Column(String(10), nullable=False, server_default=text("''"), comment='车次') launch = Column(Date, nullable=False, comment='发车时间') def __to_dict__(self) -> dict: return {c.name: str(getattr(self, c.name)) for c in self.__table__.columns}