Mercurial > public > src > rhodecode
diff pylons_app/lib/timerproxy.py @ 49:3ada2f409c1c
Added sqlalchemy support
made models for database
changed views to handle sqlalchemy
author | Marcin Kuzminski <marcin@python-blog.com> |
---|---|
date | Thu, 08 Apr 2010 01:50:46 +0200 |
parents | |
children | 0c22a870bb79 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pylons_app/lib/timerproxy.py Thu Apr 08 01:50:46 2010 +0200 @@ -0,0 +1,15 @@ +from sqlalchemy.interfaces import ConnectionProxy +import time +import logging +log = logging.getLogger(__name__) + +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 + log.info("Query: %s" % statement % parameters) + log.info("<<<<< TOTAL TIME: %f <<<<<" % total)