如何使用peewee limit()? [英] How to use peewee limit()?

查看:748
本文介绍了如何使用peewee limit()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Peewee ,我尝试按以下方式使用限制:

With Peewee I'm trying to use limit as follows:

one_ticket = Ticket.select().limit(1)
print one_ticket.count()

但是打印出5.有人知道这是怎么回事吗?

This prints out 5 however. Does anybody know what's wrong here?

推荐答案

尝试在peewee rel ="nofollow">调试模式,它实际上只是设置python logging模块来处理logging.DEBUG级项目:

Try running peewee in debug mode, which is actually just setting up the python logging module to handle logging.DEBUG level items:

import logging
logging.basicConfig(
    format='[%(asctime)-15s] [%(name)s] %(levelname)s]: %(message)s',
    level=logging.DEBUG
)

# From here, you can now perform your query, and you should see peewee's debug output using the logging module.
one_ticket = Ticket.select().limit(1)
print one_ticket.count()

理想情况下,您应该看到原始查询.

Ideally, you should see the raw query.

这篇关于如何使用peewee limit()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆