ltzliwe
V2EX  ›  问与答

使用sqlalchemy的时候

  •  
  •   ltzliwe · Dec 21, 2011 · 7555 views
    This topic created in 5256 days ago, the information mentioned may be changed or developed.
    from flaskext.sqlalchemy import SQLAlchemy

    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///models.db'

    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
    1 replies    2017-05-28 13:59:48 +08:00
    swcsend
        1
    swcsend  
       May 28, 2017
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5804 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 02:52 · PVG 10:52 · LAX 19:52 · JFK 22:52
    ♥ Do have faith in what you're doing.