Move some helper functions to db_helper.py