Skip to content

Commit cad2b0b

Browse files
authored
Connection Cleanup (#77)
1 parent ea3c10e commit cad2b0b

15 files changed

+361
-471
lines changed

snooty.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ stable-api = "Stable API"
3535
api-root = "https://pymongo.readthedocs.io/en/{+patch-version-number+}/api/"
3636
string-data-type = "``str``"
3737
int-data-type = "``int``"
38+
bool-data-type = "``bool``"

source/connect.txt

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

5787
Transport 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

178208
To 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

192221
To learn more about the {+stable-api+}, see :ref:`pymongo-stable-api`.
193222

source/connect/connect-to-mongodb.txt

Lines changed: 0 additions & 147 deletions
This file was deleted.

0 commit comments

Comments
 (0)