Search code examples
pythonpython-2.7peewee

Peewee to print generated queries


Is there a way or setting in Peewee where I can get it to print out all the queries being executed in order to debug and understand potential performance issues.


Solution

  • Yes, it is documented: http://docs.peewee-orm.com/en/latest/peewee/database.html#logging-queries

    # Print all queries to stderr.
    import logging
    logger = logging.getLogger('peewee')
    logger.setLevel(logging.DEBUG)
    logger.addHandler(logging.StreamHandler())