aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar/panels/sql.py
blob: 9b50c939115ba15ce84eb47a2248c0262d2a8929 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from debug_toolbar.panels import DebugPanel
from django.db import connection

class SQLDebugPanel(DebugPanel):
    """
    Panel that displays information about the SQL queries run while processing the request.
    """
    def title(self):
        return '%d SQL Queries' % (len(connection.queries))

    def url(self):
        return ''

    def content(self):
        query_info = []
        for q in connection.queries:
            query_info.append('<dt><strong>%s</strong></dt><dd>%s</dd>' % (q['time'], q['sql']))
        return '<dl>%s</dl>' % (''.join(query_info))