Skip to main content

peewee-ext is a peewee extension

Project description

Peewee-ext

PyPI PyPI - Downloads PyPI - Python Version PyPI - License

简介

peewee-ext 对 peewee 进行了部分扩展,在其基础上进行了增强

安装

pip install peewee-ext

说明

增加一个 DictModel 增加两个方法

from peewee import Model

class DictModel(Model):

    def to_data(self, recurse=True, backrefs=False,
                only=None, exclude=None,
                seen=None, extra_attrs=None,
                fields_from_query=None, max_depth=None,
                manytomany=False):
        """model to dict"""

    def to_dict(self):
        """model to dict"""


    def __str__(self):
        """friendly for human"""

增加两个装饰器

def to_dict(func):
    """
    model to dict , shallow convert
    """

# 返回嵌套字典
def to_data(func=None, recurse=True, backrefs=False,
            only=None, exclude=None,
            seen=None, extra_attrs=None,
            fields_from_query=None, max_depth=1,
            manytomany=False):
    """model to dict , deep convert"""

增加执行时间打印

from peewee import MySQLDatabase

class TimerMySQLDatabase(MySQLDatabase):
    """"""

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

peewee-ext-0.0.1.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

peewee_ext-0.0.1-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page