move all database interaction to database.py