Add facility to store performed queries in debug mode

Useful to have in django-debugtoolbar for example.