Factor out most of the database connection into db/open.py