MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _apply_events

Function _apply_events

test/perf/many_table_reflection.py:392–416  ·  view source on GitHub ↗
(engine)

Source from the content-addressed store, hash-verified

390
391
392def _apply_events(engine):
393 queries = defaultdict(list)
394
395 now = 0
396
397 @sa.event.listens_for(engine, "before_cursor_execute")
398 def before_cursor_execute(
399 conn, cursor, statement, parameters, context, executemany
400 ):
401 nonlocal now
402 now = time.time()
403
404 @sa.event.listens_for(engine, "after_cursor_execute")
405 def after_cursor_execute(
406 conn, cursor, statement, parameters, context, executemany
407 ):
408 total = time.time() - now
409
410 if context and context.compiled:
411 statement_str = context.compiled.string
412 else:
413 statement_str = statement
414 queries[statement_str].append(total)
415
416 return queries
417
418
419def _print_query_stats(queries):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected