Metadata-Version: 2.1
Name: falcon-sqla
Version: 0.1.0b1
Summary: Middleware for integrating Falcon applications with SQLAlchemy.
Home-page: https://github.com/vytas7/falcon-sqla
Author: Vytautas Liuolia
Author-email: vytautas.liuolia@gmail.com
License: Apache 2.0
Description: |Build Status| |codecov.io|
        
        Falcon Middleware: SQLAlchemy Integration
        =========================================
        
        The ``falcon-sqla`` package provides a middleware component for managing
        `SQLAlchemy sessions <https://docs.sqlalchemy.org/orm/session_api.html#Session>`_.
        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
        ------------
        
        .. code:: bash
        
            $ pip install falcon-sqla
        
        
        Usage
        -----
        
        The ``falcon_sqla`` session ``Manager`` can be used in two ways:
        
        * As a `Falcon middleware component
          <https://falcon.readthedocs.io/en/stable/api/middleware.html>`_
        * As a context manager to explicitly provide a database session
        
        
        Configuration
        ^^^^^^^^^^^^^
        
        * Create a SQLAlchemy engine.
        * Pass the engine to the ``Manager()`` initializer as its first parameter.
        * If using the manager as a middleware component, pass its ``middleware``
          property to the ``falcon.API()`` (to be renamed to ``falcon.App`` in
          Falcon 3.0+) initializer:
        
        .. code:: python
        
            engine = create_engine('driver+dialect://my/database')
            manager = falcon_sqla.Manager(engine)
        
            app = falcon.API(middleware=[manager.middleware])
        
            # The database session will be available as req.context.session
        
        Context Manager
        ^^^^^^^^^^^^^^^
        
        A ``falcon_sqla.Manager`` can also explicitly provide a database session using
        the ``session_scope()`` context manager:
        
        .. code:: python
        
            # Somewhere inside a responder
            with self.manager.session_scope(req, resp) as session:
                # Use the session
                # <...>
        
        Custom Vertical Partitioning
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        
        Simple random selection of read- and write- database replicas is supported
        out of the box. Use the ``add_engine()`` method to instruct the ``Manager`` to
        include the provided engines in the runtime bind selection logic:
        
        .. code:: python
        
            manager = falcon_sqla.Manager(engine)
        
            read_replica = create_engine('driver+dialect://my/database.replica')
            manager.add_engine(read_replica, 'r')
        
        
        The ``Manager.get_bind()`` method can be overridden to implement custom engine
        selection logic for more complex use cases.
        
        See also this SQLAlchemy recipe:
        `Custom Vertical Partitioning
        <https://docs.sqlalchemy.org/orm/persistence_techniques.html#custom-vertical-partitioning>`_.
        
        
        About Falcon
        ------------
        
        `Falcon <https://falconframework.org/>`_ is the minimalist web API framework
        for building reliable, correct, and high-performance REST APIs, microservices,
        proxies, and app backends in Python.
        
        
        About SQLAlchemy
        ----------------
        
        `SQLAlchemy <https://www.sqlalchemy.org/>`_ is the Python SQL toolkit and
        Object Relational Mapper that gives application developers the full power and
        flexibility of SQL.
        
        
        .. |Build Status| image:: https://api.travis-ci.org/vytas7/falcon-sqla.svg
           :target: https://travis-ci.org/vytas7/falcon-sqla
        .. |codecov.io| image:: https://codecov.io/gh/vytas7/falcon-sqla/branch/master/graphs/badge.svg
           :target: http://codecov.io/gh/vytas7/falcon-sqla
        
Keywords: falcon wsgi database middleware orm sqlalchemy
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Topic :: Database :: Front-Ends
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Requires-Python: >=3.5
Provides-Extra: test
