我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用peewee.BaseModel()。
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
def _peewee_model(): from peewee import BaseModel, Database return [BaseModel, Database]