{"id":14956746,"url":"https://github.com/deepmancer/mongo-motors","last_synced_at":"2025-10-12T19:42:20.984Z","repository":{"id":251370804,"uuid":"837217732","full_name":"deepmancer/mongo-motors","owner":"deepmancer","description":"Mongo Motors is an asynchronous, singleton-based connection pooling mechanism for MongoDB","archived":false,"fork":false,"pushed_at":"2024-12-09T15:06:07.000Z","size":26,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T04:41:54.045Z","etag":null,"topics":["async","database","mongo","mongodb","motor","nosql","nosql-database"],"latest_commit_sha":null,"homepage":"https://deepmancer.github.io/mongo-motors/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deepmancer.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":"2024-08-02T13:13:14.000Z","updated_at":"2025-03-16T06:12:24.000Z","dependencies_parsed_at":"2024-08-02T14:54:09.983Z","dependency_job_id":"0d769b3c-78dc-4d8f-b20e-176372882e19","html_url":"https://github.com/deepmancer/mongo-motors","commit_stats":null,"previous_names":["alirezaheidari-cs/mongo-motors","deepmancer/mongo-motors"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/deepmancer/mongo-motors","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmancer%2Fmongo-motors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmancer%2Fmongo-motors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmancer%2Fmongo-motors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmancer%2Fmongo-motors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepmancer","download_url":"https://codeload.github.com/deepmancer/mongo-motors/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmancer%2Fmongo-motors/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279012673,"owners_count":26085159,"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","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["async","database","mongo","mongodb","motor","nosql","nosql-database"],"created_at":"2024-09-24T13:13:26.070Z","updated_at":"2025-10-12T19:42:20.954Z","avatar_url":"https://github.com/deepmancer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌱 Mongo Motors - Async MongoDB Client\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/MongoDB-47A248.svg?style=for-the-badge\u0026logo=MongoDB\u0026logoColor=white\" alt=\"MongoDB\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/PyPI-3775A9.svg?style=for-the-badge\u0026logo=PyPI\u0026logoColor=white\" alt=\"PyPI\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/python-3670A0?style=for-the-badge\u0026logo=python\u0026logoColor=ffdd54\" alt=\"Python\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=for-the-badge\" alt=\"License\"\u003e\n\u003c/p\u003e\n\n`mongo-motors` is your go-to Python package for seamless asynchronous MongoDB operations. Built on top of the `motor` library, it provides a robust and efficient way to manage MongoDB connections, ensuring thread-safe and high-performance interactions with your database.\n\n---\n\n| **Source Code** | **Website** |\n|:-----------------|:------------|\n| \u003ca href=\"https://github.com/deepmancer/mongo-motors\" target=\"_blank\"\u003egithub.com/deepmancer/mongo-motors\u003c/a\u003e | \u003ca href=\"https://deepmancer.github.io/mongo-motors/\" target=\"_blank\"\u003edeepmancer.github.io/mongo-motors\u003c/a\u003e |\n\n---\n\n## ✨ Features\n\n- **⚡ Asynchronous MongoDB Connections:** Leverages the power of `motor` for non-blocking database operations.\n- **🔄 Singleton Design Pattern:** Manages MongoDB connections with a singleton, ensuring efficient and thread-safe usage.\n- **🔧 Easy Configuration:** Configure your MongoDB client effortlessly using `MongoConfig`.\n- **📜 Context Manager Support:** Simplifies MongoDB session management with context managers.\n- **🔗 Fully Compatible with `motor`:** Seamlessly integrates with the `motor` library for all your MongoDB needs.\n\n## 📦 Installation\n\nGet started quickly by installing `mongo-motors` using pip:\n\n```sh\npip install git+https://github.com/yourusername/mongo-motors.git\n```\n\n## 🛠️ Quick Start\n\n### 🔧 Configuration\n\nStart by creating a configuration object using `MongoConfig`:\n\n```python\nfrom mongo_motors import MongoConfig\n\nconfig = MongoConfig(\n    host='localhost',\n    port=27017,\n    db='mydatabase',\n)\n```\n\n### 🏗️ Creating an AsyncMongo Instance\n\nNext, create an instance of `AsyncMongo` using your configuration:\n\n```python\nfrom mongo_motors import AsyncMongo\n\nasync def main():\n    mongo_client = await AsyncMongo.create(config=config)\n    print(f\"Connected to MongoDB at: {mongo_client.url}\")\n```\n\n### ⚙️ Managing MongoDB Sessions\n\nInteract with your MongoDB server using the context manager from `get_or_create_session`:\n\n```python\nfrom mongo_motors import AsyncMongo\n\nasync def main():\n    mongo_client = await AsyncMongo.create(config=config)\n\n    async with mongo_client.get_or_create_session() as session:\n        # Perform MongoDB operations\n        result = await session.collection_name.insert_one({'key': 'value'})\n        document = await session.collection_name.find_one({'_id': result.inserted_id})\n        print(f\"Inserted document: {document}\")\n\n    await mongo_client.disconnect()\n```\n\n### 🔍 Example Usage\n\nHere's a complete example to demonstrate how `mongo-motors` works:\n\n```python\nimport asyncio\nfrom mongo_motors import AsyncMongo, MongoConfig\n\nasync def main():\n    config = MongoConfig(\n        host='localhost',\n        port=27017,\n        db='mydatabase',\n    )\n    client = await AsyncMongo.create(config=config)\n\n    async with client.get_or_create_session() as session:\n        # Insert a document\n        await session.collection_name.insert_one({'key': 'value'})\n        \n        # Retrieve the document\n        document = await session.collection_name.find_one({'key': 'value'})\n        print(f\"Document found: {document}\")\n        \n        # Delete documents based on a condition\n        keys = [{'key': 'value1'}, {'key': 'value2'}, {'key': 'value3'}]\n        for key in keys:\n            await session.collection_name.delete_many(key)\n        \n    await client.disconnect()\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n### 🛡️ Error Handling\n\n`mongo-motors` provides custom exceptions to handle various MongoDB-related issues:\n\n- `MongoConnectionError`\n- `MongoSessionCreationError`\n\n### 🔌 Disconnecting\n\nGracefully disconnect from your MongoDB server when you're done:\n\n```python\nawait mongo_client.disconnect()\n```\n\n## 📄 License\n\nThis project is licensed under the Apache License 2.0. For more details, see the [LICENSE](https://github.com/yourusername/mongo-motors/blob/main/LICENSE) file.\n\n---\n\n**Supercharge your MongoDB operations with `mongo-motors` today!** 🌱\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepmancer%2Fmongo-motors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepmancer%2Fmongo-motors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepmancer%2Fmongo-motors/lists"}