We are pleased to announce the 4.12.0 release of PyMongo - MongoDB’s Python Driver.
Changes in Version 4.12.0 (2025/04/08)
Warning:
Driver support for MongoDB 4.0 reached end of life in April 2025. PyMongo 4.12 will be the last release to support MongoDB 4.0.
PyMongo 4.12 brings a number of changes including:
- Support for configuring DEK cache lifetime via the
key_expiration_ms
argument to pymongo.encryption_options.AutoEncryptionOpts. - Support for $lookup in CSFLE and QE supported on MongoDB 8.1+.
- pymongocrypt>=1.13 is now required for In-Use Encryption support.
- Added gridfs.asynchronous.grid_file.AsyncGridFSBucket.rename_by_name and gridfs.grid_file.GridFSBucket.rename_by_name for more performant renaming of a file with multiple revisions.
- Added gridfs.asynchronous.grid_file.AsyncGridFSBucket.delete_by_name and gridfs.grid_file.GridFSBucket.delete_by_name for more performant deletion of a file with multiple revisions.
- AsyncMongoClient no longer performs DNS resolution for “mongodb+srv://” connection strings on creation. To avoid blocking the asyncio loop, the resolution is now deferred until the client is first connected.
- Added index hinting support to the pymongo.asynchronous.collection.AsyncCollection.distinct and pymongo.collection.Collection.distinct commands.
- Deprecated the
hedge
parameter for pymongo.read_preferences.PrimaryPreferred, ~pymongo.read_preferences.Secondary, pymongo.read_preferences.SecondaryPreferred, pymongo.read_preferences.Nearest. Support forhedge
will be removed in PyMongo 5.0. - Removed PyOpenSSL support from the asynchronous API due to limitations of the CPython asyncio.Protocol SSL implementation.
- Allow valid SRV hostnames with less than 3 parts.
Issues Resolved
See the PyMongo 4.12 release notes in JIRA for the list of resolved issues in this release.