如何使用peewee limit()?

kra*_*r65 5 python sql orm limit peewee

有了Peewee,我试图使用限制如下:

one_ticket = Ticket.select().limit(1)
print one_ticket.count()
Run Code Online (Sandbox Code Playgroud)

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

Voo*_*OFX 2

尝试peewee调试模式下运行,这实际上只是设置 pythonlogging模块来处理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()
Run Code Online (Sandbox Code Playgroud)

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