writing db.py