major rework of db.py. table creation now handled automatically. methods to handle schema upgrades. error handling and returns added to all methods.