view pylons_app/lib/timerproxy.py @ 148:d928d5f0a251

Adde raw file to routes, and refactoring updated link to raw file at file source template
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 11 May 2010 22:23:16 +0200
parents 0c22a870bb79
children a5a3bcc5ee89
line wrap: on
line source

from sqlalchemy.interfaces import ConnectionProxy
import time
import logging
log = logging.getLogger('timerproxy')

class TimerProxy(ConnectionProxy):
    def cursor_execute(self, execute, cursor, statement, parameters, context, executemany):
        now = time.time()
        try:
            log.info(">>>>> STARTING QUERY >>>>>")
            return execute(cursor, statement, parameters, context)
        finally:
            total = time.time() - now
            try:
                log.info("Query: %s" % statement % parameters)
            except TypeError:
                log.info("Query: %s %s" % (statement, parameters))
            log.info("<<<<< TOTAL TIME: %f <<<<<" % total)