Docs Menu

What's New

Learn what's new in:

In accordance with the MongoDB Software Lifecycle Schedules, an upcoming minor version of PyMongo will raise the minimum MongoDB Server version from 4.0 to 4.2. PyMongo will no longer support MongoDB Server 4.0. To learn how to upgrade your driver version, see the Upgrade PyMongo Versions guide.

Warning

Breaking Changes

PyMongo v4.11 contains breaking changes. For more information, see Version 4.11 Breaking Changes.

The PyMongo v4.11 release includes the following new features:

  • Adds support for free-threaded CPython when running Python v3.13+. For more information about free threading, see the Python documentation.

  • In-use encryption requires pymongocrypt v1.12 or later.

  • The MongoClient.address() and AsyncMongoClient.address() methods correctly block when called on unconnected clients.

  • Adds __repr__ support for the IndexModel and SearchIndexModel classes.

  • Adds a sort parameter to the following methods:

    • Collection.update_one()

    • Collection.replace_one()

    • operations.UpdateOne()

    • operations.UpdateMany()

  • The MongoClient.bulkWrite() and AsyncMongoClient.bulk_write() methods throw an error error if you use them with unacknowledged writes when the ordered or verboseResults options are set to True.

  • Fixes a bug that caused DatetimeMS to be incorrectly encoded as '{"$date": "X"}' instead of '{"$date": X}' when using the the legacy MongoDB Extended JSON datetime representation.

  • Fixes a bug that caused the bson.json_util.loads() method to raise an IndexError instead of a ValueError when parsing an invalid $date value.

The PyMongo v4.10 release includes the following new features:

  • Adds provisional support for a new binary BSON subtype (9), which can be used for efficient storage and retrieval of vectors by using the bson.binary.Binary.from_vector() and bson.binary.Binary.as_vector() methods. Support for BSON subtype 9 is in beta and is subject to change before the generally available release.

  • Adds "c" to the driver.name client metadata field when an application uses the C extension.

  • Fixes a bug that could cause AsyncMongoClient to deadlock.

Warning

Breaking Changes

PyMongo v4.9 contains breaking changes. For more information, see Version 4.9 Breaking Changes.

The PyMongo v4.9 release includes the following new features:

  • Adds support for MongoDB Server 8.0 and Python 3.13.

  • Adds support for Queryable Encryption range queries. To use this feature, your app must connect to MongoDB Server 8.0 or later. For more information about Queryable Encryption, see Queryable Encryption in the MongoDB Server manual.

  • Adds a new experimental asynchronous API as a replacement for Motor. This API is in beta and is subject to change before the generally available release.

Warning

Breaking Changes

PyMongo v4.8 contains breaking changes. For more information, see Version 4.8 Breaking Changes.

The PyMongo v4.8 release includes the following new features:

  • Implemented Secure Software Development Life Cycle (SSDLC) automation in the release process. GitHub releases include a software bill of materials (SBOM) and signature files corresponding to the distribution files released on PyPI.

  • In objects of type bson.binary.Binary, the repr() method is redacted when the binary subtype is SENSITIVE_SUBTYPE (8).

  • Fixed a bug in change streams where both the startAtOperationTime and resumeToken fields could be added to a retry attempt, which caused the retry to fail.

  • On Windows, changed handshake metadata for os.name to Windows to improve import time.

  • Improved performance of MongoClient operations, especially when the driver is running many operations concurrently.

  • Added a fallback to the stdlib ssl module if importing the pyopenssl module fails with an AttributeError.

Warning

Breaking Changes

PyMongo v4.7 contains breaking changes. For more information, see Version 4.7 Breaking Changes.

The PyMongo v4.7 release includes the following new features:

  • Added the Hello.connection_id, CommandStartedEvent.server_connection_id, CommandSucceededEvent.server_connection_id, and CommandFailedEvent.server_connection_id properties.

  • Added support for name suffixes for Key Management Service (KMS) providers for Client-Side Field Level Encryption (CSFLE). This feature requires pymongocrypt v1.9+ and libmongocrypt v1.9+. For more information, see the API documentation for the AutoEncryptionOpts class.

  • Improved the performance of encoding BSON documents to JSON.

  • The ClientEncryption.encrypt() and ClientEncryption.encrypt_expression() methods now allow the key_id argument to be passed in as a UUID Object.

  • Inflating a RawBSONDocument object containing a Code value no longer causes an error.

  • Fixed a bug in Python 3.12 where the error message RuntimeError: can't create new thread at interpreter shutdown could be written to stderr when a MongoClient thread starts as the Python interpreter is shutting down.

  • Fixed a bug where Int64 instances could not always be encoded by orjson. Code like the following example now runs correctly:

>>> import orjson
>>> from bson import json_util
>>> orjson.dumps({'a': Int64(1)}, default=json_util.default, option=orjson.OPT_PASSTHROUGH_SUBCLASS)