V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
ltzliwe
V2EX  ›  问与答

使用sqlalchemy的时候

  •  
  •   ltzliwe · 2011-12-21 13:40:59 +08:00 · 6593 次点击
    这是一个创建于 4503 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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 条回复    2017-05-28 13:59:48 +08:00
    swcsend
        1
    swcsend  
       2017-05-28 13:59:48 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1078 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 23:13 · PVG 07:13 · LAX 16:13 · JFK 19:13
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.