Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use peewee limit()?

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?

like image 903
kramer65 Avatar asked Nov 19 '13 09:11

kramer65


1 Answers

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.

like image 90
VooDooNOFX Avatar answered Nov 11 '22 04:11

VooDooNOFX