# Setup logging
log = logging.getLogger("pbs.database")
-#@sqlalchemy.event.listens_for(sqlalchemy.Engine, "before_cursor_execute")
-#def before_cursor_execute(conn, cursor, statement, parameters, context, executemany):
-# now = time.time()
-#
-# # Create a queue to store start times
-# try:
-# q = conn.info["query_start_time"]
-# except KeyError:
-# q = conn.info["query_start_time"] = queue.LifoQueue()
-#
-# # Push the start time of the query
-# q.put(now)
-#
-# # Log the statement
-# log.debug("Start Query: %s %r", statement, parameters)
-#
-#@sqlalchemy.event.listens_for(sqlalchemy.Engine, "after_cursor_execute")
-#def after_cursor_execute(conn, cursor, statement, parameters, context, executemany):
-# time_end = time.time()
-#
-# # Fetch the latest start time
-# time_start = conn.info["query_start_time"].get()
-#
-# # Compute the total time
-# t = time_end - time_start
-#
-# # Log the total runtime
-# log.debug("Query completed in %.02fms (%s row(s))", t * 1000, cursor.rowcount)
+@sqlalchemy.event.listens_for(sqlalchemy.Engine, "before_cursor_execute")
+def before_cursor_execute(conn, cursor, statement, parameters, context, executemany):
+ now = time.time()
+
+ # Create a queue to store start times
+ try:
+ q = conn.info["query_start_time"]
+ except KeyError:
+ q = conn.info["query_start_time"] = queue.LifoQueue()
+
+ # Push the start time of the query
+ q.put(now)
+
+ # Log the statement
+ log.debug("Start Query: %s %r", statement, parameters)
+
+@sqlalchemy.event.listens_for(sqlalchemy.Engine, "after_cursor_execute")
+def after_cursor_execute(conn, cursor, statement, parameters, context, executemany):
+ time_end = time.time()
+
+ # Fetch the latest start time
+ time_start = conn.info["query_start_time"].get()
+
+ # Compute the total time
+ t = time_end - time_start
+
+ # Log the total runtime
+ log.debug("Query completed in %.02fms (%s row(s))", t * 1000, cursor.rowcount)
class Base(sqlalchemy.ext.asyncio.AsyncAttrs, sqlalchemy.orm.DeclarativeBase):
"""