Factored out DB connection setup

To allow for inclusion from other parts of the system without loading
the whole app

Commit from a train 🚂