{"id":13480790,"url":"https://github.com/mongodb/mongo-python-driver","last_synced_at":"2026-01-07T20:11:34.672Z","repository":{"id":482368,"uuid":"108051","full_name":"mongodb/mongo-python-driver","owner":"mongodb","description":"PyMongo - the Official MongoDB Python driver","archived":false,"fork":false,"pushed_at":"2025-05-12T14:35:12.000Z","size":28061,"stargazers_count":4216,"open_issues_count":9,"forks_count":1117,"subscribers_count":236,"default_branch":"master","last_synced_at":"2025-05-12T14:48:09.057Z","etag":null,"topics":["mongodb","mongodb-driver","pymongo","python","python-library"],"latest_commit_sha":null,"homepage":"https://www.mongodb.com/docs/languages/python/pymongo-driver/current/","language":"Python","has_issues":false,"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/mongodb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"zenodo":null}},"created_at":"2009-01-15T15:18:06.000Z","updated_at":"2025-05-12T14:35:15.000Z","dependencies_parsed_at":"2023-07-05T15:02:50.537Z","dependency_job_id":"f96eae3b-ab9e-4acb-95d3-73e3f36baa76","html_url":"https://github.com/mongodb/mongo-python-driver","commit_stats":{"total_commits":5883,"total_committers":233,"mean_commits":"25.248927038626608","dds":0.8079211286758456,"last_synced_commit":"0733c4da44d4cd5c2a32c092762e639e14c3dc27"},"previous_names":[],"tags_count":174,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongo-python-driver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongo-python-driver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongo-python-driver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongo-python-driver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mongodb","download_url":"https://codeload.github.com/mongodb/mongo-python-driver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253776401,"owners_count":21962484,"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":["mongodb","mongodb-driver","pymongo","python","python-library"],"created_at":"2024-07-31T17:00:45.048Z","updated_at":"2026-01-07T20:11:34.666Z","avatar_url":"https://github.com/mongodb.png","language":"Python","readme":"# PyMongo\n\n[![PyPI Version](https://img.shields.io/pypi/v/pymongo)](https://pypi.org/project/pymongo)\n[![Python Versions](https://img.shields.io/pypi/pyversions/pymongo)](https://pypi.org/project/pymongo)\n[![Monthly Downloads](https://static.pepy.tech/badge/pymongo/month)](https://pepy.tech/project/pymongo)\n[![API Documentation Status](https://readthedocs.org/projects/pymongo/badge/?version=stable)](http://pymongo.readthedocs.io/en/stable/api?badge=stable)\n\n## About\n\nThe PyMongo distribution contains tools for interacting with MongoDB\ndatabase from Python. The `bson` package is an implementation of the\n[BSON format](http://bsonspec.org) for Python. The `pymongo` package is\na native Python driver for MongoDB, offering both synchronous and asynchronous APIs. The `gridfs` package is a\n[gridfs](https://github.com/mongodb/specifications/blob/master/source/gridfs/gridfs-spec.md/)\nimplementation on top of `pymongo`.\n\nPyMongo supports MongoDB 4.0, 4.2, 4.4, 5.0, 6.0, 7.0, and 8.0. PyMongo follows [semantic versioning](https://semver.org/spec/v2.0.0.html) for its releases.\n\n## Documentation\n\nDocumentation is available at\n[mongodb.com](https://www.mongodb.com/docs/languages/python/pymongo-driver/current/).\n\n[API documentation](https://pymongo.readthedocs.io/en/stable/api/) and the [full changelog](https://pymongo.readthedocs.io/en/stable/changelog.html) for each release is available at [readthedocs.io](https://pymongo.readthedocs.io/en/stable/index.html).\n\n## Support / Feedback\n\nFor issues with, questions about, or feedback for PyMongo, please look\ninto our [support channels](https://support.mongodb.com/welcome). Please\ndo not email any of the PyMongo developers directly with issues or\nquestions - you're more likely to get an answer on\n[StackOverflow](https://stackoverflow.com/questions/tagged/mongodb)\n(using a \"mongodb\" tag).\n\n## Bugs / Feature Requests\n\nThink you've found a bug? Want to see a new feature in PyMongo? Please\nopen a case in our issue management tool, JIRA:\n\n-   [Create an account and login](https://jira.mongodb.org).\n-   Navigate to [the PYTHON\n    project](https://jira.mongodb.org/browse/PYTHON).\n-   Click **Create Issue** - Please provide as much information as\n    possible about the issue type and how to reproduce it.\n\nBug reports in JIRA for all driver projects (i.e. PYTHON, CSHARP, JAVA)\nand the Core Server (i.e. SERVER) project are **public**.\n\n### How To Ask For Help\n\nPlease include all of the following information when opening an issue:\n\n-   Detailed steps to reproduce the problem, including full traceback,\n    if possible.\n\n-   The exact python version used, with patch level:\n\n```bash\npython -c \"import sys; print(sys.version)\"\n```\n\n-   The exact version of PyMongo used, with patch level:\n\n```bash\npython -c \"import pymongo; print(pymongo.version); print(pymongo.has_c())\"\n```\n\n-   The operating system and version (e.g. Windows 7, OSX 10.8, ...)\n\n-   Web framework or asynchronous network library used, if any, with\n    version (e.g. Django 1.7, mod_wsgi 4.3.0, gevent 1.0.1, Tornado\n    4.0.2, ...)\n\n### Security Vulnerabilities\n\nIf you've identified a security vulnerability in a driver or any other\nMongoDB project, please report it according to the [instructions\nhere](https://www.mongodb.com/docs/manual/tutorial/create-a-vulnerability-report/).\n\n## Installation\n\nPyMongo can be installed with [pip](http://pypi.python.org/pypi/pip):\n\n```bash\npython -m pip install pymongo\n```\n\nYou can also download the project source and do:\n\n```bash\npip install .\n```\n\nDo **not** install the \"bson\" package from pypi. PyMongo comes with\nits own bson package; running \"pip install bson\" installs a third-party\npackage that is incompatible with PyMongo.\n\n## Dependencies\n\nPyMongo supports CPython 3.9+ and PyPy3.9+.\n\nRequired dependencies:\n\nSupport for `mongodb+srv://` URIs requires [dnspython](https://pypi.python.org/pypi/dnspython)\n\nOptional dependencies:\n\nGSSAPI authentication requires\n[pykerberos](https://pypi.python.org/pypi/pykerberos) on Unix or\n[WinKerberos](https://pypi.python.org/pypi/winkerberos) on Windows. The\ncorrect dependency can be installed automatically along with PyMongo:\n\n```bash\npython -m pip install \"pymongo[gssapi]\"\n```\n\nMONGODB-AWS authentication requires\n[pymongo-auth-aws](https://pypi.org/project/pymongo-auth-aws/):\n\n```bash\npython -m pip install \"pymongo[aws]\"\n```\n\nOCSP (Online Certificate Status Protocol) requires\n[PyOpenSSL](https://pypi.org/project/pyOpenSSL/),\n[requests](https://pypi.org/project/requests/),\n[service_identity](https://pypi.org/project/service_identity/) and may\nrequire [certifi](https://pypi.python.org/pypi/certifi):\n\n```bash\npython -m pip install \"pymongo[ocsp]\"\n```\n\nWire protocol compression with snappy requires\n[python-snappy](https://pypi.org/project/python-snappy):\n\n```bash\npython -m pip install \"pymongo[snappy]\"\n```\n\nWire protocol compression with zstandard requires\n[backports.zstd](https://pypi.org/project/backports.zstd)\nwhen used with Python versions before 3.14:\n\n```bash\npython -m pip install \"pymongo[zstd]\"\n```\n\nClient-Side Field Level Encryption requires\n[pymongocrypt](https://pypi.org/project/pymongocrypt/) and\n[pymongo-auth-aws](https://pypi.org/project/pymongo-auth-aws/):\n\n```bash\npython -m pip install \"pymongo[encryption]\"\n```\nYou can install all dependencies automatically with the following\ncommand:\n\n```bash\npython -m pip install \"pymongo[gssapi,aws,ocsp,snappy,zstd,encryption]\"\n```\n\n## Examples\n\nHere's a basic example (for more see the *examples* section of the\ndocs):\n\n```pycon\n\u003e\u003e\u003e import pymongo\n\u003e\u003e\u003e client = pymongo.MongoClient(\"localhost\", 27017)\n\u003e\u003e\u003e db = client.test\n\u003e\u003e\u003e db.name\n'test'\n\u003e\u003e\u003e db.my_collection\nCollection(Database(MongoClient('localhost', 27017), 'test'), 'my_collection')\n\u003e\u003e\u003e db.my_collection.insert_one({\"x\": 10}).inserted_id\nObjectId('4aba15ebe23f6b53b0000000')\n\u003e\u003e\u003e db.my_collection.insert_one({\"x\": 8}).inserted_id\nObjectId('4aba160ee23f6b543e000000')\n\u003e\u003e\u003e db.my_collection.insert_one({\"x\": 11}).inserted_id\nObjectId('4aba160ee23f6b543e000002')\n\u003e\u003e\u003e db.my_collection.find_one()\n{'x': 10, '_id': ObjectId('4aba15ebe23f6b53b0000000')}\n\u003e\u003e\u003e for item in db.my_collection.find():\n...     print(item[\"x\"])\n...\n10\n8\n11\n\u003e\u003e\u003e db.my_collection.create_index(\"x\")\n'x_1'\n\u003e\u003e\u003e for item in db.my_collection.find().sort(\"x\", pymongo.ASCENDING):\n...     print(item[\"x\"])\n...\n8\n10\n11\n\u003e\u003e\u003e [item[\"x\"] for item in db.my_collection.find().limit(2).skip(1)]\n[8, 11]\n```\n\n## Learning Resources\n\n- MongoDB Learn - [Python\ncourses](https://learn.mongodb.com/catalog?labels=%5B%22Language%22%5D\u0026values=%5B%22Python%22%5D).\n- [Python Articles on Developer\nCenter](https://www.mongodb.com/developer/languages/python/).\n\n## Testing\n\nThe easiest way to run the tests is to run the following from the repository root.\n\n```bash\npip install -e \".[test]\"\npytest\n```\n\nFor more advanced testing scenarios, see the [contributing guide](./CONTRIBUTING.md#running-tests-locally).\n","funding_links":[],"categories":["Database","Python","Database Drivers","Database Clients","数据库 Drivers","Data Management \u0026 Processing","数据库驱动程序","Libraries","Database Drivers [🔝](#readme)","🗃️ SQL \u0026 Databases"],"sub_categories":["Database Drivers","Database \u0026 Cloud Management","Python","ASGI Servers","Tools"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb%2Fmongo-python-driver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmongodb%2Fmongo-python-driver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb%2Fmongo-python-driver/lists"}