Defined latest group and building db functions and implemented db.py to the routes.

- Edited db.py queries.
- two new db.py functions 
- imported db.py to density.py and implemented to routes
sorry, last tweak, paren should be on the next line