MongoDB PyMongo Documentation
Overview
Welcome to the documentation site for the official MongoDB PyMongo Driver. PyMongo is a Python distribution containing tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
Get Started
Learn how to install the driver, establish a connection to MongoDB, and begin working with data in the Get Started with PyMongo tutorial.
Connect to MongoDB
Learn how to create and configure a connection to a MongoDB deployment in the Connect to MongoDB section.
Databases and Collections
Learn how to use PyMongo to work with MongoDB databases and collections in the Databases and Collections section.
Write Data to MongoDB
Learn how you can write data to MongoDB in the Write Data to MongoDB section.
Read Data from MongoDB
Learn how you can retrieve data from MongoDB in the Read Data from MongoDB section.
Run a Database Command
Learn how to run a database command in the Run a Database Command section.
Optimize Queries with Indexes
Learn how to work with common types of indexes in the Optimize Queries with Indexes section.
Transform Your Data with Aggregation
Learn how to use PyMongo to perform aggregation operations in the Transform Your Data with Aggregation section.
Secure Your Data
Learn about ways you can authenticate your application and encrypt your data in the Secure Your Data section.
Specialized Data Formats
Learn how to work with specialized data formats and custom types in the Specialized Data Formats section.
Third-Party Tools
For a list of popular third-party Python libraries for working with MongoDB, see the Third-Party Tools section.
Frequently Asked questions
For answers to commonly asked questions about PyMongo, see the Frequently Asked Questions section.
Troubleshooting
For solutions to issues you might encounter when using the driver, see the Troubleshooting section.
What's New
For a list of new features and changes in each version, see the What's New section.
Upgrade PyMongo Versions
Learn what changes you might need to make to your application to upgrade driver versions in the Upgrade PyMongo Versions section.
Migrate from Motor to PyMongo Async
In September 2024, MongoDB released the experimental PyMongo Async driver as a replacement for Motor, the previous asynchronous MongoDB driver for Python. Learn how to migrate from Motor to the PyMongo Async driver in the Migrate from Motor to PyMongo Async section.
Switch from PyMongo to PyMongo Async
Learn what changes you need to make to switch from PyMongo to the experimental PyMongo Async driver in the Switch from PyMongo to PyMongo Async section.
Previous Versions
For documentation on versions of the driver v4.6.x and earlier, see the Previous Versions section.
Issues & Help
Learn how to report bugs, contribute to the driver, and find help in the Issues & Help section.
Compatibility
For compatibility tables that show the recommended PyMongo version to use for specific Python and MongoDB Server versions, see the Compatibility section.
API Documentation
For detailed information about types and methods in PyMongo, see the PyMongo API documentation.