DRY database.py and add more imports