Metadata-Version: 2.4
Name: Flask-Storm
Version: 2.0.0
Summary: Storm integration for Flask.
Author: Andreas Runfalk
Author-email: Andreas Runfalk <andreas@runfalk.se>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Flask
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Database
Classifier: Topic :: Utilities
Classifier: Topic :: Software Development :: Libraries
Requires-Dist: flask>=2.2
Requires-Dist: storm>=0.21
Requires-Dist: sqlparse>=0.2.2 ; extra == 'fancy'
Requires-Python: >=3.11
Project-URL: Homepage, https://github.com/runfalk/flask-storm
Project-URL: Documentation, https://runfalk.github.io/flask-storm
Provides-Extra: fancy
Description-Content-Type: text/x-rst

Flask-Storm
===========
|test-status| |pypi-version|

Flask-Storm is an extension for `Flask <https://www.palletsprojects.com/p/flask/>`_ that adds support for Canonical's ORM `Storm <https://storm.canonical.com/>`_ to your application. Flask-Storm automatically opens and closes database connections on demand when requests need them.


Example
-------
Access to the database is done using the `store` `application context local <http://flask.pocoo.org/docs/0.11/appcontext/>`_. Within an application context this variable holds a reference to a Storm Store instance. If no connection is opened it will automatically open one. When the application context is torn down, normally after the request has returned, the store is closed.

.. code-block:: python

    from flask_storm import store
    from storm.locals import Int, Unicode

    class User(object):
        __storm_table__ = "users"

        id = Int(primary=True)
        name = Unicode()


    @app.route("/")
    def index():
        # Get name of user with ID 1
        return store.get(User, 1).name


Installation
------------

Flask-Storm is tested Python 3.11 or newer.

.. code-block:: bash

    pip install flask_storm[fancy]

This installs Flask-Storm with SQL highlighting and reformatting support. If you do not want this drop the ``fancy``.

.. code-block:: bash

    pip install flask_storm


Documentation
-------------
Documentation is available on `<https://runfalk.github.io/flask-storm>`_


Development
-----------

Install `uv <https://docs.astral.sh/uv/getting-started/installation/>`_ first.

.. code-block:: bash

    # Setup environment
    uv sync --extra fancy

    # Run test suite
    uv run --extra fancy pytest

    # Build documentation
    uv run sphinx-build doc/ doc-build/

    # Run auto formatter
    uv run ruff format flask_storm/ tests/

    # Run linter
    uv run ruff check flask_storm/ tests/

    # Build source and wheel distributions
    uv build


.. |test-status| image:: https://github.com/runfalk/flask-storm/actions/workflows/ci.yml/badge.svg
    :alt: Test status
    :scale: 100%
    :target: https://travis-ci.org/runfalk/Flask-Storm

.. |pypi-version| image:: https://badge.fury.io/py/Flask-Storm.svg
    :alt: PyPI version status
    :scale: 100%
    :target: https://pypi.python.org/pypi/Flask-Storm/

See the `changelog <https://runfalk.github.io/flask-storm/changelog.html>`_
for release history.
