Moved database connection code to a single file