code: def install_sql_hook():
      
      try:
          from django.db.backends.utils import CursorWrapper
      except ImportError:
          from django.db.backends.util import CursorWrapper
  
      try:
          real_execute = CursorWrapper.execute
          real_executemany = CursorWrapper.executemany
      except AttributeError:
          # XXX(mitsuhiko): On some very old django versions (<1.6) this
          # trickery would have to look different but I can't be bothered.
          return
  
      def record_sql(vendor, alias, start, duration, sql, params):
          def processor(data):
              real_sql, real_params = format_sql(sql, params)
              if real_params:
                  real_sql = real_sql % tuple(real_params)
              # maybe category to 'django.%s.%s' % (vendor, alias or
              #   'default') ?
              data.update({
                  'message': real_sql,
                  'category': 'query',
              })
          breadcrumbs.record(processor=processor)
  
      def record_many_sql(vendor, alias, start, sql, param_list):
          duration = time.time() - start
          for params in param_list:
              record_sql(vendor, alias, start, duration, sql, params)
  
      def execute(self, sql, params=None):
          start = time.time()
          try:
              return real_execute(self, sql, params)
          finally:
              record_sql(self.db.vendor, getattr(self.db, 'alias', None),
                         start, time.time() - start, sql, params)
  
      def executemany(self, sql, param_list):
          start = time.time()
          try:
              return real_executemany(self, sql, param_list)
          finally:
              record_many_sql(self.db.vendor, getattr(self.db, 'alias', None),
                              start, sql, param_list)
  
      CursorWrapper.execute = execute
      CursorWrapper.executemany = executemany
      breadcrumbs.ignore_logger('django.db.backends')
docs: If installed this causes Django's queries to be captured.