@@ -1012,6 +1012,21 @@ def get_database(self, name, codec_options=None,
10121012 """Get a :class:`~pymongo.database.Database` with the given name and
10131013 options.
10141014
1015+ Useful for creating a :class:`~pymongo.database.Database` with
1016+ different codec options, read preference, and/or write concern from
1017+ this :class:`MongoClient`.
1018+
1019+ >>> client.read_preference
1020+ Primary()
1021+ >>> db1 = client.test
1022+ >>> db1.read_preference
1023+ Primary()
1024+ >>> from pymongo import ReadPreference
1025+ >>> db2 = client.get_database(
1026+ ... 'test', read_preference=ReadPreference.SECONDARY)
1027+ >>> db2.read_preference
1028+ Secondary(tag_sets=None)
1029+
10151030 :Parameters:
10161031 - `name`: The name of the database - a string.
10171032 - `codec_options` (optional): An instance of
@@ -1020,7 +1035,8 @@ def get_database(self, name, codec_options=None,
10201035 used.
10211036 - `read_preference` (optional): The read preference to use. If
10221037 ``None`` (the default) the :attr:`read_preference` of this
1023- :class:`MongoClient` is used.
1038+ :class:`MongoClient` is used. See :mod:`~pymongo.read_preferences`
1039+ for options.
10241040 - `write_concern` (optional): An instance of
10251041 :class:`~pymongo.write_concern.WriteConcern`. If ``None`` (the
10261042 default) the :attr:`write_concern` of this :class:`MongoClient` is
0 commit comments