More DB Fixes

Moved DB code into app.py becaue importing it as an object was not
working.