1234567891011121314151617181920212223242526 |
- from sqlalchemy import Boolean, Column, Date, DateTime, Integer, String
- from sqlalchemy.orm import declarative_base
- Base = declarative_base()
- class UserModel(Base):
- __tablename__ = "rest_user"
- id = Column(Integer, primary_key=True, autoincrement=True, )
- name = Column(String)
- birthday = Column(Date)
- insys = Column(Boolean)
- idrole = Column(Integer)
- lastlogintime = Column(DateTime)
- email = Column(String)
- password = Column(String)
- def as_dict(self):
- return {c.name: getattr(self, c.name) for c in self.__table__.columns}
- class RoleModel(Base):
- __tablename__ = 'rest_role'
- id = Column(Integer, primary_key=True, autoincrement=True, )
- name = Column(String, unique=True, nullable=False)
- def as_dict(self):
- return {c.name: getattr(self, c.name) for c in self.__table__.columns}
|