app.config['SQLALCHEMY_DATABASE_URI'] = "mysql://root:xxx@127.0.0.1/xxx"
app.config["SQLALCHEMY_BINDS"]={
"sqlite_test":"sqlite:///database.db"
}
配置如上?
我有一个需求是执行
db.session.execute("select xxxx")
这个execute方法默认会在mysql中查找。
我想要在上面配置的sqlite中查找,请问要如何做呢?
我google了以下,发现了一条这个,但是没有结果。
https://github.com/mitsuhiko/flask-sq…
好吧自己找到答案了。
db.session.execute("select xxx",bind=db.get_engine(current_app,bind="sqlite_test")).fetchall()
正文完