##// END OF EJS Templates
moved sqlalchemy session to base.
moved sqlalchemy session to base.

File last commit:

r90:0c22a870 default
r151:988477a0 default
Show More
timerproxy.py
18 lines | 691 B | text/x-python | PythonLexer
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)