@csrf_exempt
def sql_profile(request):
 form = SQLSelectForm((request.POST or None))
 if form.is_valid():
  sql = form.cleaned_data[u'raw_sql']
  params = form.cleaned_data[u'params']
  cursor = form.cursor
  result = None
  headers = None
  result_error = None
  try:
   cursor.execute(u'SET PROFILING=1')
   cursor.execute(sql, params)
   cursor.execute(u'SET PROFILING=0')
   cursor.execute(u'\n  SELECT  *\n    FROM  information_schema.profiling\n   WHERE  query_id = (\n          SELECT  query_id\n            FROM  information_schema.profiling\n        ORDER BY  query_id DESC\n           LIMIT  1\n        )\n')
   headers = [d[0] for d in cursor.description]
   result = cursor.fetchall()
  except Exception:
   result_error = u'Profiling is either not available or not supported by your database.'
  cursor.close()
  context = {u'result': result, u'result_error': result_error, u'sql': form.reformat_sql(), u'duration': form.cleaned_data[u'duration'], u'headers': headers, u'alias': form.cleaned_data[u'alias']}
  return render_to_response(u'debug_toolbar/panels/sql_profile.html', context)
 return HttpResponseBadRequest(u'Form errors')

@ csrf_exempt def sql_profile ( request ) : form = SQLSelectForm ( ( request . POST or None ) ) if form . is_valid ( ) : sql = form . cleaned_data [ u'raw_sql' ] params = form . cleaned_data [ u'params' ] cursor = form . cursor result = None headers = None result_error = None try : cursor . execute ( u'SET PROFILING=1' ) cursor . execute ( sql , params ) cursor . execute ( u'SET PROFILING=0' ) cursor . execute ( u'\n  SELECT  *\n    FROM  information_schema.profiling\n   WHERE  query_id = (\n          SELECT  query_id\n            FROM  information_schema.profiling\n        ORDER BY  query_id DESC\n           LIMIT  1\n        )\n' ) headers = [ d [ 0 ] for d in cursor . description ] result = cursor . fetchall ( ) except Exception : result_error = u'Profiling is either not available or not supported by your database.' cursor . close ( ) context = { u'result' : result , u'result_error' : result_error , u'sql' : form . reformat_sql ( ) , u'duration' : form . cleaned_data [ u'duration' ] , u'headers' : headers , u'alias' : form . cleaned_data [ u'alias' ] } return render_to_response ( u'debug_toolbar/panels/sql_profile.html' , context ) return HttpResponseBadRequest ( u'Form errors' )
returns the output of running the sql and getting the profiling statistics .