from sqlalchemy import Column, Date, Integer, String, text from base import db class Hotel(db.Model): __tablename__ = 'faker_hotel' id = Column(Integer, primary_key=True, comment='id') hotel_code = Column(String(10), nullable=False, server_default=text("''"), comment='酒店编号') hotel_name = Column(String(50), nullable=False, server_default=text("''"), comment='酒店名') locate_city_id = Column(String(10), nullable=False, server_default=text("''"), comment='酒店所在城市ID') identification = Column(String(18), server_default=text("''"), comment='入住者身份证号') in_data = Column(Date, nullable=False, comment='入住日期') out_data = Column(Date, nullable=False, comment='离开日期') def __to_dict__(self) -> dict: return {c.name: str(getattr(self, c.name)) for c in self.__table__.columns}