db = SQLAlchemy() #把这两行换成 db = SQLAlchemy(app)就正确了 db.init_app(app)
class Role(db.Model): ...
有这样的错误。。 为什么呢 raise RuntimeError('application not registered on db ' RuntimeError: application not registered on db instance and no application bound to current context