quart-db


Namequart-db JSON
Version 0.10.1 PyPI version JSON
download
home_pageNone
SummaryQuart-DB is a Quart extension that provides managed connection(s) to database(s).
upload_time2025-08-20 17:32:42
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
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": null,
    "name": "quart-db",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "pgjones <philip.graham.jones@googlemail.com>",
    "download_url": "https://files.pythonhosted.org/packages/36/e8/f2fd6bef7407ecc3a5f51a4a4df196ea36b5505792818900f9a0df0343b4/quart_db-0.10.1.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",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Quart-DB is a Quart extension that provides managed connection(s) to database(s).",
    "version": "0.10.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ea56c56558ebd6d5655bf82dfe64d8d6ac465152776d92705f71d11d503aa3c0",
                "md5": "99e58412d6818e2ad516dc130ac9d8f1",
                "sha256": "2124de922a7fd656f42f6672d354a7117317a3fb0498e1949dcc7afa407142b2"
            },
            "downloads": -1,
            "filename": "quart_db-0.10.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "99e58412d6818e2ad516dc130ac9d8f1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 16354,
            "upload_time": "2025-08-20T17:32:41",
            "upload_time_iso_8601": "2025-08-20T17:32:41.366299Z",
            "url": "https://files.pythonhosted.org/packages/ea/56/c56558ebd6d5655bf82dfe64d8d6ac465152776d92705f71d11d503aa3c0/quart_db-0.10.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "36e8f2fd6bef7407ecc3a5f51a4a4df196ea36b5505792818900f9a0df0343b4",
                "md5": "9749ebad7104b607f94284a4bcc44a5f",
                "sha256": "7a8d5c70a624fc5644429ba77cc9dc34c155192eefe34394b760c989c15ea630"
            },
            "downloads": -1,
            "filename": "quart_db-0.10.1.tar.gz",
            "has_sig": false,
            "md5_digest": "9749ebad7104b607f94284a4bcc44a5f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 14683,
            "upload_time": "2025-08-20T17:32:42",
            "upload_time_iso_8601": "2025-08-20T17:32:42.868879Z",
            "url": "https://files.pythonhosted.org/packages/36/e8/f2fd6bef7407ecc3a5f51a4a4df196ea36b5505792818900f9a0df0343b4/quart_db-0.10.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-20 17:32:42",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "quart-db"
}
        
Elapsed time: 2.92821s