Show More
@@ -1,15 +1,18 b'' | |||
|
1 | 1 | from sqlalchemy.interfaces import ConnectionProxy |
|
2 | 2 | import time |
|
3 | 3 | import logging |
|
4 |
log = logging.getLogger( |
|
|
4 | log = logging.getLogger('timerproxy') | |
|
5 | 5 | |
|
6 | 6 | class TimerProxy(ConnectionProxy): |
|
7 | 7 | def cursor_execute(self, execute, cursor, statement, parameters, context, executemany): |
|
8 | 8 | now = time.time() |
|
9 | 9 | try: |
|
10 | 10 | log.info(">>>>> STARTING QUERY >>>>>") |
|
11 | 11 | return execute(cursor, statement, parameters, context) |
|
12 | 12 | finally: |
|
13 | 13 | total = time.time() - now |
|
14 | try: | |
|
14 | 15 | log.info("Query: %s" % statement % parameters) |
|
16 | except TypeError: | |
|
17 | log.info("Query: %s %s" % (statement, parameters)) | |
|
15 | 18 | log.info("<<<<< TOTAL TIME: %f <<<<<" % total) |
General Comments 0
You need to be logged in to leave comments.
Login now