abstract database connection into model