Storm integration for Flask.
Project description
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
------------
.. 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
-----------
.. code-block:: bash
# Setup environment
python3 -m venv --prompt=flask-storm .venv
source .venv/bin/activate
pip install --upgrade pip setuptools
pip install -e .[dev,fancy]
# Run test suite
pytest
# You can test all supported python versions in one go using tox
tox
# Build documentation
sphinx-build doc/ doc-build/
# Run auto formatter
black flask_storm/ tests/ setup.py
# Run linter
flake8 flask_storm/ tests/ setup.py
.. |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/
.. Include changelog on PyPI
Changelog
=========
Version are structured like the following: ``<major>.<minor>.<bugfix>``. Unless
explicitly stated, changes are made by
`Andreas Runfalk <https://github.com/runfalk>`_.
Version 1.0.0
-------------
Released on 23rd May 2021
- Dropped support for Python 3.3
- Dropped support for Python 3.4
- Dropped support for Python 3.5
- Updated documentation to work with newer Sphinx versions
- Support upstream Storm 0.21 or newer (thank you
`Colin Watson <https://github.com/cjwatson>`_)
- Fixed broken placeholder replacement when using SQL statement printing in
Python 3 (thank you `Colin Watson <https://github.com/cjwatson>`_)
- Fixed problem where ``fancy`` would always be set to ``False`` regardless of
the provided value when it was specified to a tracer.
Note that dropped Python versions may still work, but that's accidental rather
than intentional.
Version 0.2.0
-------------
Released on 8th October 2018
- Added Python 3 support
- Removed ``storm`` as a dependency since ``storm-legacy`` can be used as well
Version 0.1.2
-------------
Released on 14th June 2017
- Fixed an issue with query logging in ``flask shell`` and PostgreSQL
Version 0.1.1
-------------
Released on 9th June 2017
- Fixed issue with new versions of sqlparse by bumping its version requirement
Version 0.1.0
-------------
Released on 19 July 2016
- Initial release
===========
|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
------------
.. 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
-----------
.. code-block:: bash
# Setup environment
python3 -m venv --prompt=flask-storm .venv
source .venv/bin/activate
pip install --upgrade pip setuptools
pip install -e .[dev,fancy]
# Run test suite
pytest
# You can test all supported python versions in one go using tox
tox
# Build documentation
sphinx-build doc/ doc-build/
# Run auto formatter
black flask_storm/ tests/ setup.py
# Run linter
flake8 flask_storm/ tests/ setup.py
.. |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/
.. Include changelog on PyPI
Changelog
=========
Version are structured like the following: ``<major>.<minor>.<bugfix>``. Unless
explicitly stated, changes are made by
`Andreas Runfalk <https://github.com/runfalk>`_.
Version 1.0.0
-------------
Released on 23rd May 2021
- Dropped support for Python 3.3
- Dropped support for Python 3.4
- Dropped support for Python 3.5
- Updated documentation to work with newer Sphinx versions
- Support upstream Storm 0.21 or newer (thank you
`Colin Watson <https://github.com/cjwatson>`_)
- Fixed broken placeholder replacement when using SQL statement printing in
Python 3 (thank you `Colin Watson <https://github.com/cjwatson>`_)
- Fixed problem where ``fancy`` would always be set to ``False`` regardless of
the provided value when it was specified to a tracer.
Note that dropped Python versions may still work, but that's accidental rather
than intentional.
Version 0.2.0
-------------
Released on 8th October 2018
- Added Python 3 support
- Removed ``storm`` as a dependency since ``storm-legacy`` can be used as well
Version 0.1.2
-------------
Released on 14th June 2017
- Fixed an issue with query logging in ``flask shell`` and PostgreSQL
Version 0.1.1
-------------
Released on 9th June 2017
- Fixed issue with new versions of sqlparse by bumping its version requirement
Version 0.1.0
-------------
Released on 19 July 2016
- Initial release
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Flask-Storm-1.0.0.tar.gz
(23.7 kB
view details)
Built Distribution
File details
Details for the file Flask-Storm-1.0.0.tar.gz
.
File metadata
- Download URL: Flask-Storm-1.0.0.tar.gz
- Upload date:
- Size: 23.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f342e497dbfc369106c13dd7fb3785614b42ce7c27023a8f81c32b527c5e44f |
|
MD5 | ec0bfa94c25624e15ef7bdbed1d89a5b |
|
BLAKE2b-256 | 3f8b68b680f1af68ee287180a67ec2883bcf19c83de60cbae901743a4bf1e0f0 |
File details
Details for the file Flask_Storm-1.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: Flask_Storm-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa6655c0d0479b6c559733a05b257f84073e5e6c8390f3f4646539d877dd4705 |
|
MD5 | e25f668f347fd0a7f9167e4378d73a32 |
|
BLAKE2b-256 | acbb0d4fa6e2432a2cf3087f2a4c91005fff0caf8f00465c5697dfdf545b1da4 |