separate db methods from handler.py