{"id":28764944,"url":"https://github.com/klen/muffin-databases","last_synced_at":"2025-07-15T12:39:57.963Z","repository":{"id":50864904,"uuid":"337997572","full_name":"klen/muffin-databases","owner":"klen","description":"Async support for a range of databases for Muffin Framework","archived":false,"fork":false,"pushed_at":"2024-11-01T11:07:25.000Z","size":148,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-06-11T21:01:43.332Z","etag":null,"topics":["asyncio","muffin","sql"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/klen.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":".github/code_of_conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/codeowners","security":".github/security.md","support":null}},"created_at":"2021-02-11T10:33:59.000Z","updated_at":"2024-11-01T11:07:29.000Z","dependencies_parsed_at":"2022-09-09T20:22:45.898Z","dependency_job_id":null,"html_url":"https://github.com/klen/muffin-databases","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/klen/muffin-databases","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klen%2Fmuffin-databases","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klen%2Fmuffin-databases/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klen%2Fmuffin-databases/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klen%2Fmuffin-databases/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/klen","download_url":"https://codeload.github.com/klen/muffin-databases/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klen%2Fmuffin-databases/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265437175,"owners_count":23765116,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asyncio","muffin","sql"],"created_at":"2025-06-17T10:13:01.915Z","updated_at":"2025-07-15T12:39:57.952Z","avatar_url":"https://github.com/klen.png","language":"Python","readme":"Muffin-Databases\n################\n\n.. _description:\n\n**Muffin-Databases** -- Async support for a range of databases for Muffin_ Framework\n\n.. _badges:\n\n.. image:: https://github.com/klen/muffin-databases/workflows/tests/badge.svg\n    :target: https://github.com/klen/muffin-databases/actions\n    :alt: Tests Status\n\n.. image:: https://img.shields.io/pypi/v/muffin-databases\n    :target: https://pypi.org/project/muffin-databases/\n    :alt: PYPI Version\n\n.. image:: https://img.shields.io/pypi/pyversions/muffin-databases\n    :target: https://pypi.org/project/muffin-databases/\n    :alt: Python Versions\n\n.. _contents:\n\n.. contents::\n\n.. _requirements:\n\nRequirements\n=============\n\n- python \u003e= 3.9\n\n.. note:: The plugin supports only asyncio evenloop (not trio)\n\n.. _installation:\n\nInstallation\n=============\n\n**Muffin-Databases** should be installed using pip: ::\n\n    $ pip install muffin-databases\n\nOptionally you can install the required database drivers with: ::\n\n    $ pip install muffin-databases[sqlite]\n    $ pip install muffin-databases[postgres]\n    $ pip install muffin-databases[mysql]\n\nDriver support is provided using one of asyncpg_, aiomysql_, or aiosqlite_.\n\n.. _usage:\n\nUsage\n=====\n\nSetup the plugin and connect it into your app:\n\n.. code-block:: python\n\n    from muffin import Application\n    from muffin_databases import Plugin as DB\n\n    # Create Muffin Application\n    app = Application('example')\n\n    # Initialize the plugin\n    # As alternative: db = DB(app, **options)\n    db = DB(url='sqlite:///db.sqlite')\n    db.setup(app)\n\n\nThat's it now you are able to use the plugin inside your views:\n\n.. code-block:: python\n\n    @app.route('/items', methods=['GET'])\n    async def get_items(request):\n        \"\"\"Return a JSON with items from database.\"\"\"\n        rows = await db.fetch_all('SELECT * from items')\n        return [dict(row.items()) for row in rows]\n\n    @app.route('/items', methods=['POST'])\n    async def insert_item(request):\n        \"\"\"Store an item into database.\"\"\"\n        data = await request.data()  # parse formdata/json from the request\n        await db.execute_many('INSERT INTO items (name, value) VALUES (:name, :value)', values=data)\n        return 'OK'\n\nThe Muffin-Databases plugin is based on databases_. See the databases_'s docs for further references.\n\n\nOptions\n-------\n\n=========================== ======================================= ===========================\nName                        Default value                           Desctiption\n--------------------------- --------------------------------------- ---------------------------\n**url**                     ``\"sqlite:///db.sqlite\"``               A database connection URL\n**params**                  ``{}``                                  A database connection params\n=========================== ======================================= ===========================\n\n\nYou are able to provide the options when you are initiliazing the plugin:\n\n.. code-block:: python\n\n    db.setup(app, url='postgresql://localhost/example', params={'ssl': True, 'min_size': 5, 'max_size': 20})\n\nOr setup it from ``Muffin.Application`` configuration using the ``DATABASES_`` prefix:\n\n.. code-block:: python\n\n   DATABASES_URL = 'postgresql://localhost/example'\n\n``Muffin.Application`` configuration options are case insensitive\n\n.. _bugtracker:\n\nBug tracker\n===========\n\nIf you have any suggestions, bug reports or\nannoyances please report them to the issue tracker\nat https://github.com/klen/muffin-databases/issues\n\n.. _contributing:\n\nContributing\n============\n\nDevelopment of Muffin-Databases happens at: https://github.com/klen/muffin-databases\n\n\nContributors\n=============\n\n* klen_ (Kirill Klenov)\n\n.. _license:\n\nLicense\n========\n\nLicensed under a `MIT license`_.\n\n.. _links:\n\n\n.. _klen: https://github.com/klen\n.. _Muffin: https://github.com/klen/muffin\n\n.. _asyncpg: https://github.com/MagicStack/asyncpg\n.. _aiomysql: https://aiomysql.readthedocs.io/en/latest/\n.. _aiosqlite: https://github.com/omnilib/aiosqlite\n.. _databases: https://www.encode.io/databases/\n\n.. _MIT license: http://opensource.org/licenses/MIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklen%2Fmuffin-databases","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fklen%2Fmuffin-databases","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklen%2Fmuffin-databases/lists"}