@@ -22,6 +22,8 @@ Connect to MongoDB
2222 :titlesonly:
2323 :maxdepth: 1
2424
25+ /connect/mongoclient
26+ /connect/connection-targets
2527 /connect/tls
2628 /connect/network-compression
2729 /connect/server-selection
@@ -52,7 +54,35 @@ the relevant values for your MongoDB deployment.
5254 :language: python
5355 :copyable: true
5456 :linenos:
55- :emphasize-lines: 5-7
57+ :emphasize-lines: 4-6
58+
59+ Connection
60+ ----------
61+
62+ Local Deployment
63+ ~~~~~~~~~~~~~~~~
64+
65+ .. code-block:: python
66+
67+ uri = "mongodb://localhost:27017/"
68+ client = MongoClient(uri)
69+
70+ Atlas
71+ ~~~~~
72+
73+ .. code-block:: python
74+
75+ uri = "<Atlas connection string>"
76+ client = MongoClient(uri, server_api=pymongo.server_api.ServerApi(
77+ version="1", strict=True, deprecation_errors=True))
78+
79+ Replica Set
80+ ~~~~~~~~~~~
81+
82+ .. code-block:: python
83+
84+ uri = "mongodb://<replica set member>:<port>/?replicaSet=<replica set name>"
85+ client = MongoClient(uri)
5686
5787Transport Layer Security (TLS)
5888------------------------------
@@ -173,7 +203,7 @@ Server Selection
173203.. code-block:: python
174204
175205 client = pymongo.MongoClient("mongodb://<username>:<password>@<hostname>:<port>",
176- server_selector=<selector function>)
206+ server_selector=<selector function>)
177207
178208To learn more about customizing server selection, see
179209:ref:`pymongo-server-selection`.
@@ -182,12 +212,11 @@ To learn more about customizing server selection, see
182212--------------
183213
184214.. code-block:: python
185- :emphasize-lines: 4
186215
187216 from pymongo.server_api import ServerApi
188217
189218 client = pymongo.MongoClient("mongodb://<username>:<password>@<hostname:<port>",
190- server_api=ServerApi("<{+stable-api+} version>"))
219+ server_api=ServerApi("<{+stable-api+} version>"))
191220
192221To learn more about the {+stable-api+}, see :ref:`pymongo-stable-api`.
193222
0 commit comments