Python peewee 模块,BaseModel() 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用peewee.BaseModel()

项目:ssr-panel-sanic    作者:gaolycn    | 项目源码 | 文件源码
def _get_meta_db_class(db):
    """creating a declartive class model for db
    """
    class _BlockedMeta(BaseModel):
        def __new__(cls, name, bases, attrs):
            _instance = super(_BlockedMeta, cls).__new__(cls, name, bases, attrs)
            _instance.objects = AsyncManager(_instance, db)
            return _instance

    class _Base(Model, metaclass=_BlockedMeta):

        def to_dict(self):
            return self._data

        class Meta:
            database = db
    return _Base
项目:wsgicli    作者:kobinpy    | 项目源码 | 文件源码
def _peewee_model():
    from peewee import BaseModel, Database
    return [BaseModel, Database]