django.db.connection request - add a key

8 views
Skip to first unread message

hiwd

unread,
Jun 14, 2008, 12:07:21 AM6/14/08
to Django developers

Small request, just for debugging purposes...

When viewing the generated sql using django.db.connection.queries
array I want to see the index of the query, the ID if you will, to
help me debug.

Currently, class CursorDebugWrapper's execute method is building the
array of dicts with the keys 'sql' and 'time'.

Locally I added an 'index' key as well...

self.db.queries.append({
'sql': sql,
'time': "%.3f" % (stop - start),
'index': self.db.queries.__len__()
})

so now when I execute:

>>>connection.queries[-1]
>>>{'index': 23, 'time': '0.003', 'sql': u'SELECT...'}

I find it helpful enough, so I thought I'd throw it out there, but ya
know... small request.

Collin Grady

unread,
Jun 14, 2008, 12:16:00 AM6/14/08
to django-d...@googlegroups.com
hiwd said the following:
> 'index': self.db.queries.__len__()

Shouldn't that be len(self.db.queries) ? :)

--
Collin Grady

We are not anticipating any emergencies.

Reply all
Reply to author
Forward
0 new messages