quart-db


Namequart-db JSON
Version 0.8.3 PyPI version JSON
download
home_pagehttps://github.com/pgjones/quart-db/
SummaryQuart-DB is a Quart extension that provides managed connection(s) to database(s).
upload_time2024-08-29 13:46:15
maintainerNone
docs_urlNone
authorpgjones
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Quart-DB
========

|Build Status| |docs| |pypi| |python| |license|

Quart-DB is a Quart extension that provides managed connection(s) to
postgresql or sqlite database(s).

Quickstart
----------

Quart-DB is used by associating it with an app and a DB (via a URL)
and then utilising the ``g.connection`` connection,

.. code-block:: python

   from quart import g, Quart, websocket
   from quart_db import QuartDB

   app = Quart(__name__)
   db = QuartDB(app, url="postgresql://user:pass@localhost:5432/db_name")

   @app.get("/<int:id>")
   async def get_count(id: int):
       result = await g.connection.fetch_val(
           "SELECT COUNT(*) FROM tbl WHERE id = :id",
           {"id": id},
       )
       return {"count": result}

   @app.post("/")
   async def set_with_transaction():
       async with g.connection.transaction():
           await db.execute("UPDATE tbl SET done = :done", {"done": True})
           ...
       return {}

   @app.get("/explicit")
   async def explicit_usage():
        async with db.connection() as connection:
            ...

Contributing
------------

Quart-DB is developed on `GitHub
<https://github.com/pgjones/quart-db>`_. If you come across an issue,
or have a feature request please open an `issue
<https://github.com/pgjones/quart-db/issues>`_. If you want to
contribute a fix or the feature-implementation please do (typo fixes
welcome), by proposing a `merge request
<https://github.com/pgjones/quart-db/merge_requests>`_.

Testing
~~~~~~~

The best way to test Quart-DB is with `Tox
<https://tox.readthedocs.io>`_,

.. code-block:: console

    $ pip install tox
    $ tox

this will check the code style and run the tests.

Help
----

The Quart-DB `documentation
<https://quart-db.readthedocs.io/en/latest/>`_ is the best places to
start, after that try searching `stack overflow
<https://stackoverflow.com/questions/tagged/quart>`_ or ask for help
`on gitter <https://gitter.im/python-quart/lobby>`_. If you still
can't find an answer please `open an issue
<https://github.com/pgjones/quart-db/issues>`_.


.. |Build Status| image:: https://github.com/pgjones/quart-db/actions/workflows/ci.yml/badge.svg
   :target: https://github.com/pgjones/quart-db/commits/main

.. |docs| image:: https://readthedocs.org/projects/quart-db/badge/?version=latest&style=flat
   :target: https://quart-db.readthedocs.io/en/latest/

.. |pypi| image:: https://img.shields.io/pypi/v/quart-db.svg
   :target: https://pypi.python.org/pypi/Quart-DB/

.. |python| image:: https://img.shields.io/pypi/pyversions/quart-db.svg
   :target: https://pypi.python.org/pypi/Quart-DB/

.. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg
   :target: https://github.com/pgjones/quart-db/blob/main/LICENSE


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pgjones/quart-db/",
    "name": "quart-db",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "pgjones",
    "author_email": "philip.graham.jones@googlemail.com",
    "download_url": "https://files.pythonhosted.org/packages/0c/35/1741723fbfb3837cdf7f6aa73bae8e253f3332045597c73fedb3c22c5853/quart_db-0.8.3.tar.gz",
    "platform": null,
    "description": "Quart-DB\n========\n\n|Build Status| |docs| |pypi| |python| |license|\n\nQuart-DB is a Quart extension that provides managed connection(s) to\npostgresql or sqlite database(s).\n\nQuickstart\n----------\n\nQuart-DB is used by associating it with an app and a DB (via a URL)\nand then utilising the ``g.connection`` connection,\n\n.. code-block:: python\n\n   from quart import g, Quart, websocket\n   from quart_db import QuartDB\n\n   app = Quart(__name__)\n   db = QuartDB(app, url=\"postgresql://user:pass@localhost:5432/db_name\")\n\n   @app.get(\"/<int:id>\")\n   async def get_count(id: int):\n       result = await g.connection.fetch_val(\n           \"SELECT COUNT(*) FROM tbl WHERE id = :id\",\n           {\"id\": id},\n       )\n       return {\"count\": result}\n\n   @app.post(\"/\")\n   async def set_with_transaction():\n       async with g.connection.transaction():\n           await db.execute(\"UPDATE tbl SET done = :done\", {\"done\": True})\n           ...\n       return {}\n\n   @app.get(\"/explicit\")\n   async def explicit_usage():\n        async with db.connection() as connection:\n            ...\n\nContributing\n------------\n\nQuart-DB is developed on `GitHub\n<https://github.com/pgjones/quart-db>`_. If you come across an issue,\nor have a feature request please open an `issue\n<https://github.com/pgjones/quart-db/issues>`_. If you want to\ncontribute a fix or the feature-implementation please do (typo fixes\nwelcome), by proposing a `merge request\n<https://github.com/pgjones/quart-db/merge_requests>`_.\n\nTesting\n~~~~~~~\n\nThe best way to test Quart-DB is with `Tox\n<https://tox.readthedocs.io>`_,\n\n.. code-block:: console\n\n    $ pip install tox\n    $ tox\n\nthis will check the code style and run the tests.\n\nHelp\n----\n\nThe Quart-DB `documentation\n<https://quart-db.readthedocs.io/en/latest/>`_ is the best places to\nstart, after that try searching `stack overflow\n<https://stackoverflow.com/questions/tagged/quart>`_ or ask for help\n`on gitter <https://gitter.im/python-quart/lobby>`_. If you still\ncan't find an answer please `open an issue\n<https://github.com/pgjones/quart-db/issues>`_.\n\n\n.. |Build Status| image:: https://github.com/pgjones/quart-db/actions/workflows/ci.yml/badge.svg\n   :target: https://github.com/pgjones/quart-db/commits/main\n\n.. |docs| image:: https://readthedocs.org/projects/quart-db/badge/?version=latest&style=flat\n   :target: https://quart-db.readthedocs.io/en/latest/\n\n.. |pypi| image:: https://img.shields.io/pypi/v/quart-db.svg\n   :target: https://pypi.python.org/pypi/Quart-DB/\n\n.. |python| image:: https://img.shields.io/pypi/pyversions/quart-db.svg\n   :target: https://pypi.python.org/pypi/Quart-DB/\n\n.. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg\n   :target: https://github.com/pgjones/quart-db/blob/main/LICENSE\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Quart-DB is a Quart extension that provides managed connection(s) to database(s).",
    "version": "0.8.3",
    "project_urls": {
        "Homepage": "https://github.com/pgjones/quart-db/",
        "Repository": "https://github.com/pgjones/quart-db/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c7a2ed63b51dba4007619f6fb055fbfe16e9622b36af6d8fc21e5ea9359b165",
                "md5": "249b1fb72015cbac766c94f734d197d9",
                "sha256": "9439906af25c403d23218c3242978c18ac833b10ed6c773a1878e428fa2d1c67"
            },
            "downloads": -1,
            "filename": "quart_db-0.8.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "249b1fb72015cbac766c94f734d197d9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 13329,
            "upload_time": "2024-08-29T13:46:14",
            "upload_time_iso_8601": "2024-08-29T13:46:14.078573Z",
            "url": "https://files.pythonhosted.org/packages/4c/7a/2ed63b51dba4007619f6fb055fbfe16e9622b36af6d8fc21e5ea9359b165/quart_db-0.8.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0c351741723fbfb3837cdf7f6aa73bae8e253f3332045597c73fedb3c22c5853",
                "md5": "a1fd07c6579e806215c57f84366a558b",
                "sha256": "3993d6903aa06ec8a95f71442c387c5256bbdaa0a3882c88fef70a8845f6547d"
            },
            "downloads": -1,
            "filename": "quart_db-0.8.3.tar.gz",
            "has_sig": false,
            "md5_digest": "a1fd07c6579e806215c57f84366a558b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 11575,
            "upload_time": "2024-08-29T13:46:15",
            "upload_time_iso_8601": "2024-08-29T13:46:15.821275Z",
            "url": "https://files.pythonhosted.org/packages/0c/35/1741723fbfb3837cdf7f6aa73bae8e253f3332045597c73fedb3c22c5853/quart_db-0.8.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-29 13:46:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pgjones",
    "github_project": "quart-db",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "quart-db"
}
        
Elapsed time: 0.33081s