How to achieve a read only connection using pymongo
问题 How to achieve a read-only connection to the secondary nodes of the MongoDB. I have a primary node and two secondary nodes. I want a read-only connection to secondary nodes. I tried MongoReplicaSetClient but did not get what I wanted. Is it possible to have a read-only connection to primary node? 回答1: You'll want to specify a Read Preference on your queries. A read preference of Secondary Preferred will send queries to a Secondary node but will fall back to the Primary in the event that a