Ticket #229 (closed defect: fixed)
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
Note: See
TracTickets for help on using
tickets.
