Refactor common_db client code