-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-2388 Begin PyMongo 4.0 migration guide #540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
PyMongo 4 Migration Guide | ||
========================= | ||
|
||
.. contents:: | ||
|
||
.. testsetup:: | ||
|
||
from pymongo import MongoClient, ReadPreference | ||
client = MongoClient() | ||
collection = client.my_database.my_collection | ||
|
||
PyMongo 4.0 brings a number of improvements as well as some backward breaking | ||
changes. This guide provides a roadmap for migrating an existing application | ||
from PyMongo 3.x to 4.x or writing libraries that will work with both | ||
PyMongo 3.x and 4.x. | ||
|
||
PyMongo 3 | ||
--------- | ||
|
||
The first step in any successful migration involves upgrading to, or | ||
requiring, at least that latest version of PyMongo 3.x. If your project has a | ||
requirements.txt file, add the line "pymongo >= 3.12, < 4.0" until you have | ||
completely migrated to PyMongo 4. Most of the key new methods and options from | ||
PyMongo 4.0 are backported in PyMongo 3.12 making migration much easier. | ||
|
||
.. note:: Users of PyMongo 2.X who wish to upgrade to 4.x must first upgrade | ||
to PyMongo 3.x by following the :doc:`migrate-to-pymongo3`. | ||
|
||
Python 3.6+ | ||
----------- | ||
|
||
PyMongo 4.0 drops support for Python 2.7, 3.4, and 3.5. Users who wish to | ||
upgrade to 4.x must first upgrade to Python 3.6+. Users upgrading from | ||
Python 2 should consult the :doc:`python3`. | ||
|
||
Enable Deprecation Warnings | ||
--------------------------- | ||
|
||
:exc:`DeprecationWarning` is raised by most methods removed in PyMongo 4.0. | ||
Make sure you enable runtime warnings to see where deprecated functions and | ||
methods are being used in your application:: | ||
|
||
python -Wd <your application> | ||
|
||
Warnings can also be changed to errors:: | ||
|
||
python -Wd -Werror <your application> | ||
|
||
.. note:: Not all deprecated features raise :exc:`DeprecationWarning` when | ||
used. See `Removed features with no migration path`_. | ||
|
||
Removed features with no migration path | ||
--------------------------------------- |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a similar note to the one above to address the unsupported interpreter versions? E.g.
.. note:: Python 2.7, 3.4, and 3.5 users who wish to upgrade to PyMongo 4.x must first upgrade to Python 3.6+. See [add link to resource] for information on upgrading Python versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.