How to use peewee limit()?

此生再无相见时 提交于 2019-12-10 14:22:11

问题


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

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

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


回答1:


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.



来源:https://stackoverflow.com/questions/20067273/how-to-use-peewee-limit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!