Reporting: update non-ORM bits to know about separate database

There is a little bit of code in the reporting web interface that
uses raw SQL rather than the django ORM.  This bypassed the database
router functionality (since there is no model to bind to).  Django
supports keeping track of multiple connections in the raw SQL interface,
so this commit does the refactoring necessary to support the multiple
databases.