The current Flask-Session implementation provides support for NoSQL options, such as MongoDB and Redis, but no support for SQL options, such as Oracle, MySQL, or SQLServer, etc.
Adding support for Flask-SQLAlchemy backed sessions adds support for all SQL options that Flask-SQLAlchemy supports. Here is a simple example of using Flask-SQLAlchemy with Flask-Session.
import os
from flask import Flask
from flask.ext.session import Session
from flask.ext.sqlalchemy import SQLAlchemy
SECRET_KEY = os.urandom(24)
SESSION_TYPE = 'sqlalchemy'
SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/database.db'
app = Flask(__name__)
app.config.from_object(__name__)
db = SQLAlchemy(app)
app.config['SESSION_SQLALCHEMY'] = db
Session(app)
Simply specify SESSION_TYPE = 'sqlalchemy' and set SESSION_SQLALCHEMY to an instance of Flask-SQLAlchemy. Instantiate the Session with the app set up to use Flask-SQLAlchemy.
Special thanks to Viswa Vutharkar for his effort in implementing the new Flask-SQLAlchemy backed session implementation. If fills a gap in Flask-Session by adding support for SQL datastores.
The current Flask-Session implementation provides support for NoSQL options, such as MongoDB and Redis, but no support for SQL options, such as Oracle, MySQL, or SQLServer, etc.
Adding support for Flask-SQLAlchemy backed sessions adds support for all SQL options that Flask-SQLAlchemy supports. Here is a simple example of using Flask-SQLAlchemy with Flask-Session.
Simply specify
SESSION_TYPE = 'sqlalchemy'
and setSESSION_SQLALCHEMY
to an instance of Flask-SQLAlchemy. Instantiate theSession
with theapp
set up to use Flask-SQLAlchemy.Special thanks to Viswa Vutharkar for his effort in implementing the new Flask-SQLAlchemy backed session implementation. If fills a gap in Flask-Session by adding support for SQL datastores.