Fix typo
Rewrite db.py to use a global context for the db in each request