finished database.py