added db utils from http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-iv-database