我有一个使用烧瓶炼金术的烧瓶应用程序:from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config.from_pyfile(filename='settings.py', silent=True)
db = SQLAlchemy(app=app)
我想从守护进程连接到同一个数据库。在daemon中,我只导入db并使用db.engine.execute进行SQLAlchemy查询。
但当守护进程启动时,主应用程序无法连接到数据库。
在日志中我看到:
^{pr2}$
我尝试使用隔离级别:from fdb.fbcore import ISOLATION_LEVEL_READ_COMMITED_LEGACY
class TPBAlchemy(SQLAlchemy):
def apply_driver_hacks(self, app_, info, options):
if 'isolation_level' not in options:
options['isolation_level'] = ISOLATION_LEVEL_READ_COMMITED_LEGACY
return super(TPBAlchemy, self).apply_driver_hacks(app_, info, options)
然后替换这个:db = SQLAlchemy()
收件人:db = TPBAlchemy()
但这只会造成另一个错误:TypeError: Invalid argument(s) 'isolation_level' sent to create_engine(),
using configuration FBDialect_fdb/QueuePool/Engine. Please check that the
keyword arguments are appropriate for this combination of components.
如果能举出完整的例子来解决我的问题,我将不胜感激。在