-
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
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`. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
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 | ||
--------------------------------------- |
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.
Nit: can we move this to the top of the section?
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.