Modified to remove mongodb and replace with Flask-SQLAlchemy