Skip to content

To prefer MongoClient instead of Connection class in PyMongo #893

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions source/use-cases/product-catalog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -526,27 +526,26 @@ per-connection or per-operation basis. In :api:`PyMongo
<pymongo.collection.Collection.read_preference>` argument.

The
:py:attr:`SECONDARY <pymongo:pymongo.connection.Connection.read_preference>`
:py:attr:`SECONDARY <pymongo:pymongo.mongo_client.MongoClient.read_preference>`
property in the following example, permits reads from a
:term:`secondary` (as well as a primary) for the entire connection .

.. code-block:: python

conn = pymongo.Connection(read_preference=pymongo.SECONDARY)
conn = pymongo.MongoClient(read_preference=pymongo.SECONDARY)

Conversely, the
:py:attr:`SECONDARY_ONLY <pymongo:pymongo.connection.Connection.read_preference>`
:py:attr:`SECONDARY_ONLY <pymongo:pymongo.mongo_client.MongoClient.read_preference>`
read preference means that the
client will only send read operation only to the secondary member

.. code-block:: python

conn = pymongo.Connection(read_preference=pymongo.SECONDARY_ONLY)
conn = pymongo.MongoClient(read_preference=pymongo.SECONDARY_ONLY)

You can also specify
:py:attr:`read_preference <pymongo.collection.Collection.read_preference>`
for specific queries,
as follows:
:py:class:`read_preference <pymongo.read_preferences.ReadPreference>`
for specific queries, as follows:

.. code-block:: python

Expand Down
2 changes: 1 addition & 1 deletion source/use-cases/storing-log-data.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ using PyMongo, with an event from the Apache Log:
>>> import bson
>>> import pymongo
>>> from datetime import datetime
>>> conn = pymongo.Connection()
>>> conn = pymongo.MongoClient()
>>> db = conn.event_db
>>> event = {
... _id: bson.ObjectId(),
Expand Down