Format according to PEPs

Cleanup imports
Add IDEA IDE files to git ignore
Some more DB foo and PEP8 formatting