<s> from django . db . backends import BaseDatabaseWrapper <EOL> from debug_toolbar . panels . sql import SQLDebugPanel <EOL> from debug_toolbar . middleware import DebugToolbarMiddleware <EOL> from debug_toolbar . utils . tracking import replace_call <EOL> @ replace_call ( BaseDatabaseWrapper . cursor ) <EOL> def cursor ( func , self ) : <EOL> djdt = DebugToolbarMiddleware . get_current ( ) <EOL> if djdt : <EOL> djdt . _panels [ SQLDebugPanel ] = djdt . get_panel ( SQLLoggingPanel ) <EOL> return func ( self ) <EOL> class SQLLoggingPanel ( SQLDebugPanel ) : <EOL> """<STR_LIT>""" <EOL> def process_response ( self , request , response ) : <EOL> super ( SQLLoggingPanel , self ) . process_response ( request , response ) <EOL> if getattr ( request , '<STR_LIT>' , { } ) . get ( '<STR_LIT>' , False ) : <EOL> self . nav_subtitle ( ) <EOL> for alias , query in self . _queries : <EOL> query [ '<STR_LIT>' ] = alias <EOL> stats = { } <EOL> queries = [ q for a , q in self . _queries ] <EOL> if request . debug_logging [ '<STR_LIT>' ] : <EOL> stats [ '<STR_LIT>' ] = queries <EOL> stats [ '<STR_LIT>' ] = self . _sql_time <EOL> stats [ '<STR_LIT>' ] = len ( queries ) <EOL> request . debug_logging_stats . update ( stats ) </s>
