Converted to Flask-sqlalchemy version