Moves the database connection to the app context

Fixes #66