model.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:fleaker 作者: croscon 项目源码 文件源码
def get_by_id(cls, record_id, execute=True):
        """Return a single instance of the model queried by ID.

        Args:
            record_id (int): Integer representation of the ID to query on.

        Keyword Args:
            execute (bool, optional):
                Should this method execute the query or return a query object
                for further manipulation?

        Returns:
            cls | :py:class:`peewee.SelectQuery`:
                If ``execute`` is ``True``, the query is executed, otherwise
                a query is returned.

        Raises:
            :py:class:`peewee.DoesNotExist`:
                Raised if a record with that ID doesn't exist.
        """
        query = cls.base_query().where(cls.id == record_id)

        if execute:
            return query.get()

        return query
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号