This commit is contained in:
parent
0e701020bb
commit
0febd91b25
|
@ -34,14 +34,13 @@ Base = declarative_base()
|
|||
@event.listens_for(Engine, 'before_cursor_execute')
|
||||
def before_cursor_execute(conn, cursor, statement, parameters, context, executemany):
|
||||
conn.info.setdefault('query_start_time', []).append(time.time())
|
||||
logger.debug(f"\n{statement}")
|
||||
|
||||
@event.listens_for(Engine, 'after_cursor_execute')
|
||||
def after_cursor_execute(conn, cursor, statement, parameters, context, executemany):
|
||||
total = time.time() - conn.info['query_start_time'].pop(-1)
|
||||
stars = '*' * math.floor(total*1000)
|
||||
if stars:
|
||||
logger.debug(f' {stars} {total*1000} s\n')
|
||||
logger.debug(f'{statement}\n{stars} {total*1000} s\n')
|
||||
|
||||
def local_session(src=''):
|
||||
return Session(bind=engine, expire_on_commit=False)
|
||||
|
|
Loading…
Reference in New Issue
Block a user