如何使用peewee limit()?

时间:2013-11-19 09:06:34

标签: python sql orm limit peewee

使用Peewee我尝试使用限制如下:

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

但这打印出5。有人知道这里有什么问题吗?

1 个答案:

答案 0 :(得分:2)

尝试在debug mode中运行peewee,这实际上只是设置python logging模块来处理logging.DEBUG级别的项目:

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()

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