{"id":19045419,"url":"https://github.com/marirs/quart-motor","last_synced_at":"2025-04-23T23:44:32.789Z","repository":{"id":45958465,"uuid":"277118730","full_name":"marirs/quart-motor","owner":"marirs","description":"Motor support for Quart applications","archived":false,"fork":false,"pushed_at":"2024-02-17T08:27:29.000Z","size":71,"stargazers_count":17,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T01:20:01.213Z","etag":null,"topics":["asyncio","flask","mongodb","motor","pymongo","python3","quart","quart-motor"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marirs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-04T13:49:31.000Z","updated_at":"2024-10-02T12:31:15.000Z","dependencies_parsed_at":"2024-11-16T03:12:46.131Z","dependency_job_id":"0be5d793-eae4-481a-8a65-2d6929d4c633","html_url":"https://github.com/marirs/quart-motor","commit_stats":{"total_commits":36,"total_committers":8,"mean_commits":4.5,"dds":0.6666666666666667,"last_synced_commit":"dcb107f6bc3146e230a4d0318b9eafcbc34d6784"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marirs%2Fquart-motor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marirs%2Fquart-motor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marirs%2Fquart-motor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marirs%2Fquart-motor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marirs","download_url":"https://codeload.github.com/marirs/quart-motor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250535055,"owners_count":21446504,"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","flask","mongodb","motor","pymongo","python3","quart","quart-motor"],"created_at":"2024-11-08T22:50:10.289Z","updated_at":"2025-04-23T23:44:32.431Z","avatar_url":"https://github.com/marirs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Quart-Motor\n=============\n[![Build Status](https://travis-ci.org/marirs/quart-motor.svg?branch=master)](https://travis-ci.org/marirs/quart-motor)\n[![codecov](https://codecov.io/gh/marirs/quart-motor/branch/master/graph/badge.svg)](https://codecov.io/gh/marirs/quart-motor)\n[![GitHub license](https://img.shields.io/badge/license-BSD%203-brightgreen)](https://github.com/marirs/quart-motor/blob/master/LICENSE)\n![PyPI - Downloads](https://img.shields.io/pypi/dd/Quart-Motor)\n\n`MongoDB \u003chttp://www.mongodb.org/\u003e` is an open source database that stores\nflexible JSON-like \"documents,\" which can have any number, name, or\nhierarchy of fields within, instead of rows of data as in a relational\ndatabase. Python developers can think of MongoDB as a persistent, searchable\nrepository of Python dictionaries (and, in fact, this is how `PyMongo\n\u003chttp://api.mongodb.org/python/current/\u003e` represents MongoDB documents).\n\nQuart-Motor bridges Quart and Motor and provides some convenience\nhelpers.\n\n\nQuickstart\n----------\n\nFirst, install Quart-Motor:\n\n```bash\n$ pip install Quart-Motor\n```\n\nNext, add a :class:`~quart_motor.Motor` to your code:\n\n```python\n    from quart import Quart\n    from quart_motor import Motor\n\n    app = Quart(__name__)\n    app.config[\"MONGO_URI\"] = \"mongodb://localhost:27017/myDatabase\"\n    mongo = Motor(app)\n```\n:class:`~quart_motor.Motor` connects to the MongoDB server running on\nport 27017 on localhost, to the database named ``myDatabase``. This database\nis exposed as the :attr:`~quart_motor.Motor.db` attribute.\n\nYou can use :attr:`~quart_motor.Motor.db` directly in views:\n\n```python\n\n    @app.route(\"/\")\n    def home_page():\n        online_users = mongo.db.users.find({\"online\": True})\n        return render_template(\"index.html\",\n            online_users=online_users)\n```\n\nCompatibility\n-------------\n\nQuart-Motor depends on recent versions of Quart, Motor and PyMongo, where \"recent\"\nis defined to mean \"was released in the last 3 years\". Quart-Motor *may*\nwork with older versions, but compatibility fixes for older versions will\nnot be accepted, and future changes may break compatibility in older\nversions.\n\nQuart-Motor is tested against `supported versions\n\u003chttps://www.mongodb.com/support-policy\u003e`_ of MongoDB, 3.5+.\n\nQuart-Motor works very well with\n- `uvicorn` asgi\n- `hypercorn` asgi\n\nQuart-Motor is tested against `Python 3.7+` versions.\n\nHelpers\n-------\n\nQuart-Motor provides helpers for some common tasks:\n\n.. automethod:: quart_motor.wrappers.Collection.find_one_or_404\n\n.. automethod:: quart_motor.Motor.send_file\n\n.. automethod:: quart_motor.Motor.save_file\n\n.. autoclass:: quart_motor.helpers.BSONObjectIdConverter\n\n.. autoclass:: quart_motor.helpers.JSONEncoder\n\nConfiguration\n-------------\n\nYou can configure Quart-Motor either by passing a `MongoDB URI\n\u003chttps://docs.mongodb.com/manual/reference/connection-string/\u003e`_ to the\n:class:`~quart_motor.Motor` constructor, or assigning it to the\n``MONGO_URI`` `Quart configuration variable\n\u003chttps://pgjones.gitlab.io/quart/how_to_guides/configuration.html\u003e`_\n\nThe :class:`~quart_motor.Motor` instnace also accepts these additional\ncustomization options:\n\n* ``json_options``, a :class:`~bson.json_util.JSONOptions` instance which\n  controls the JSON serialization of MongoDB objects when used with\n  :func:`~quart.json.jsonify`.\n\nYou may also pass additional keyword arguments to the ``Motor``\nconstructor. These are passed directly through to the underlying\n:class:`~motor.motor_asyncio.AsyncIOMotorClient` object.\n\nNote:\n\n    By default, Quart-Motor sets the ``connect`` keyword argument to\n    ``False``, to prevent Motor from connecting immediately. Motor\n    itself `is not fork-safe\n    \u003chttps://pymongo.readthedocs.io/en/stable/faq.html#is-pymongo-fork-safe\u003e`_,\n    and delaying connection until the app is actually used is necessary to\n    avoid issues. If you wish to change this default behavior, pass\n    ``connect=True`` as a keyword argument to ``Motor``.\n\nYou can create multiple ``Motor`` instances, to connect to multiple\ndatabases or database servers:\n\n```python\n\n    app = Quart(__name__)\n\n    # connect to MongoDB with the defaults\n    mongo1 = Motor(app, uri=\"mongodb://localhost:27017/databaseOne\")\n\n    # connect to another MongoDB database on the same host\n    mongo2 = Motor(app, uri=\"mongodb://localhost:27017/databaseTwo\")\n\n    # connect to another MongoDB server altogether\n    mongo3 = Motor(app, uri=\"mongodb://another.host:27017/databaseThree\")\n```\nEach instance is independent of the others and shares no state.\n\n\nAPI\n===\n\nClasses\n-------\n\n.. autoclass:: quart_motor.Motor\n   :members:\n\n   .. attribute:: cx\n\n      The :class:`~quart_motor.wrappers.AsyncIOMotorClient` connected to the\n      MongoDB server.\n\n   .. attribute:: db\n\n      The :class:`~quart_motor.wrappers.AsyncIOMotorDatabase` if the URI used\n      named a database, and ``None`` otherwise.\n\n\nWrappers\n--------\n\nQuart-Motor wraps Motor's :class:`~motor.motor_asyncio.AsyncIOMotorClient`,\n:class:`~motor.motor_asyncio.AsyncIOMotorDatabase`, and\n:class:`~motor.motor_asyncio.AsyncIOMotorCollection` classes, and overrides their\nattribute and item accessors. Wrapping the Motor classes in this way lets\nQuart-Motor add methods to ``AsyncIOMotorCollection`` while allowing user code to use\nMongoDB-style dotted expressions.\n\n```python\n\n    \u003e\u003e\u003e type(mongo.cx)\n    \u003ctype 'quart_motor.wrappers.AsyncIOMotorClient'\u003e\n    \u003e\u003e\u003e type(mongo.db)\n    \u003ctype 'quart_motor.wrappers.AsyncIOMotorDatabase'\u003e\n    \u003e\u003e\u003e type(mongo.db.some_collection)\n    \u003ctype 'quart_motor.wrappers.AsyncIOMotorCollection'\u003e\n```\n.. autoclass:: quart_motor.wrappers.AsyncIOMotorCollection(...)\n   :members:\n\n\nHistory and Contributors\n------------------------\n\nChanges:\n\n- 2.4.0: Unreleased\n\n  - Flask-PyMongo port as released of Flask-PyMongo.\n\nFlask-PyMongo:\n\n- \u003chttps://github.com/dcrosta/flask-pymongo\u003e\n\n\nContributors of Flask-PyMongo:\n\n- `jeverling \u003chttps://github.com/jeverling\u003e`\n- `tang0th \u003chttps://github.com/tang0th\u003e`\n- `Fabrice Aneche \u003chttps://github.com/akhenakh\u003e`\n- `Thor Adam \u003chttps://github.com/thoradam\u003e`\n- `Christoph Herr \u003chttps://github.com/jarus\u003e`\n- `Mark Unsworth \u003chttps://github.com/markunsworth\u003e`\n- `Kevin Funk \u003chttps://github.com/k-funk\u003e`\n- `Ben Jeffrey \u003chttps://github.com/jeffbr13\u003e`\n- `Emmanuel Valette \u003chttps://github.com/karec\u003e`\n- `David Awad \u003chttps://github.com/DavidAwad\u003e`\n- `Robson Roberto Souza Peixoto \u003chttps://github.com/robsonpeixoto\u003e`\n- `juliascript \u003chttps://github.com/juliascript\u003e`\n- `Henrik Blidh \u003chttps://github.com/hbldh\u003e`\n- `jobou \u003chttps://github.com/jbouzekri\u003e`\n- `Craig Davis \u003chttps://github.com/blade2005\u003e`\n- `ratson \u003chttps://github.com/ratson\u003e`\n- `Abraham Toriz Cruz \u003chttps://github.com/categulario\u003e`\n- `MinJae Kwon \u003chttps://github.com/mingrammer\u003e`\n- `yarobob \u003chttps://github.com/yarobob\u003e`\n- `Andrew C. Hawkins \u003chttps://github.com/achawkins\u003e`\n\nContributors of Quart-Motor\n\n- `Sriram \u003chttps://github.com/marirs\u003e`\n- `Kiran \u003chttps://github.com/kirantambe\u003e`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarirs%2Fquart-motor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarirs%2Fquart-motor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarirs%2Fquart-motor/lists"}