有没有人找到将Flask-Session卸载到另一个数据库的方法?我有一个主数据库COOL_APP
和一个只有会话表COOL_APP_SESSION
的数据库。我找不到任何使这种情况发生的参考,试图使用bind和flask_sqlalchemy元数据,但只能猜测。好奇是否有人取得了成功。
REF:https://pythonhosted.org/Flask-Session/
# base config
SQLALCHEMY_DATABASE_URI = 'mysql+mysqlconnector://app_user:secret_password@localhost/COOL_APP'
SQLALCHEMY_BINDS = {
'SESSION': 'mysql+mysqlconnector://app_user:secret_password@localhost/COOL_APP_SESSION'
}
# SESSION_SQLALCHEMY = ?? {per docs would be A
# flask.ext.sqlalchemy.SQLAlchemy instance whose database connection
# URI is configured using the SQLALCHEMY_DATABASE_URI parameter}
SESSION_TYPE = 'sqlalchemy'
SESSION_SQLALCHEMY_TABLE = 'Session'
PERMANENT_SESSION_LIFETIME = 360
# __init__
from flask_session import Session
sess = Session()
sess.init_app(app)