base.py 656 Bytes
Newer Older
1 2 3 4 5 6 7 8
# -*- encoding: utf-8 -*-
# -----------------------------------------------------------------------------
# @File Name  : base.py
# @Time       : 2020/11/18 下午12:47
# @Author     : X. Peng
# @Email      : acepengxiong@163.com
# @Software   : PyCharm
# -----------------------------------------------------------------------------
9
from sqlalchemy.ext.declarative import declarative_base, declared_attr
10
Base = declarative_base()
赵杰's avatar
赵杰 committed
11 12 13
metadata = Base.metadata


14 15
class BaseModel():
    """."""
16
    __abstract__ = True
17 18 19 20 21 22

    def __init__(self):
        pass

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}
23 24