@@ -52,11 +52,11 @@ At this point all of our nodes are up and running, but the set has yet
5252to be initialized. Until the set is initialized no node will become
5353the primary, and things are essentially "offline".
5454
55- To initialize the set we need to connect to a single node and run the
56- initiate command::
55+ To initialize the set we need to connect directly to a single node and run the
56+ initiate command using the `` directConnection `` option ::
5757
5858 >>> from pymongo import MongoClient
59- >>> c = MongoClient('localhost', 27017)
59+ >>> c = MongoClient('localhost', 27017, directConnection=True )
6060
6161.. note :: We could have connected to any of the other nodes instead,
6262 but only the node we initiate from is allowed to contain any
@@ -81,15 +81,19 @@ The initial connection as made above is a special case for an
8181uninitialized replica set. Normally we'll want to connect
8282differently. A connection to a replica set can be made using the
8383:meth: `~pymongo.mongo_client.MongoClient ` constructor, specifying
84- one or more members of the set, along with the replica set name. Any of
85- the following connects to the replica set we just created::
84+ one or more members of the set and optionally the replica set name.
85+ Any of the following connects to the replica set we just created::
8686
87+ >>> MongoClient('localhost')
88+ MongoClient(host=['localhost:27017'], ...)
8789 >>> MongoClient('localhost', replicaset='foo')
8890 MongoClient(host=['localhost:27017'], replicaset='foo', ...)
8991 >>> MongoClient('localhost:27018', replicaset='foo')
9092 MongoClient(['localhost:27018'], replicaset='foo', ...)
9193 >>> MongoClient('localhost', 27019, replicaset='foo')
9294 MongoClient(['localhost:27019'], replicaset='foo', ...)
95+ >>> MongoClient('mongodb://localhost:27017,localhost:27018/')
96+ MongoClient(['localhost:27017', 'localhost:27018'], ...)
9397 >>> MongoClient('mongodb://localhost:27017,localhost:27018/?replicaSet=foo')
9498 MongoClient(['localhost:27017', 'localhost:27018'], replicaset='foo', ...)
9599
0 commit comments