Reputation: 13
I've got three mongod nodes, added to replicaSet(for example localhost:27001,27002,27003). How to connect to it from pymongo if application doesn't know which node is Primary?
Upvotes: 1
Views: 743
Reputation: 4423
You need only to supply each of the replicas and the driver will select the primary for you. See documentation here:
pymongo Conneting to Replica Set
Specifically
>>> Connection("mongodb://morton.local:27017,morton.local:27018,morton.local:27019")
Connection(['morton.local:27019', 'morton.local:27017', 'morton.local:27018'])
Upvotes: 1