fixed bug in db.py