Falcon Middleware: SQLAlchemy Integration
The falcon-sqla
package provides a middleware component for managing
SQLAlchemy sessions.
The manager component can also serve as a base building block or a recipe for
more complex use cases, such as applications leveraging multiple database
binds.
Installation
Simply install the falcon-sqla package from PyPi:
$ pip install falcon-sqla
For more installation options, see Installation.
Usage
Configuring the falcon_sqla.Manager
middleware in a
falcon.App:
engine = create_engine('dialect+driver://my/database')
manager = falcon_sqla.Manager(engine)
app = falcon.App(middleware=[manager.middleware])
# The database session will be available as req.context.session
More usage scenarios are covered in the User Guide.