Created a factory that managers the db connection