Fixed database connection bug

- Connect to database before each request instead of maintaining an
  open connection
- Store connection in g object, which is available in the request
  context
- Updated functions to use g.db instead of taking a connection object
Merge pull request #56 from RuddockHouse/database_fix

Fixed database connection bug