fixes in db.py