Ticket #229 (closed defect: fixed)

Opened 4 months ago

Last modified 4 months ago

pagestats - queries number

Reported by: JensDiemer Owned by: JensDiemer
Priority: trivial Milestone: v0.8.5
Component: system Keywords:
Cc:

Description

IMHO only the database debug cursor holds connection.queries So if DEBUG is off we always see 0 queries, that's wrong ;)

We can fix it like this:

class DatabaseStatTracker(util.CursorDebugWrapper):
    """
Replacement for CursorDebugWrapper which stores additional information
in `connection.queries`.
"""
    def execute(self, sql, params=()):
        start = time.time()
        try:
            return self.cursor.execute(sql, params)
        finally:
            stop = time.time()
            # We keep `sql` to maintain backwards compatibility
            self.db.queries.append({
                'sql': self.db.ops.last_executed_query(self.cursor, sql, params),
                'time': stop - start,
                'raw_sql': sql,
                'params': simplejson.dumps(params),
            })
util.CursorDebugWrapper = DatabaseStatTracker

from: http://github.com/robhudson/django-debug-toolbar/tree/master/debug_toolbar/panels/sql.py

Change History

Changed 4 months ago by JensDiemer

  • owner changed from jens to JensDiemer

Changed 4 months ago by JensDiemer

  • status changed from new to closed
  • resolution set to fixed

fixed in changeset:1772

Note: See TracTickets for help on using tickets.