Writing API, db connect part