skip to Main Content

Mongodb – Pymongo how to set read_preference

How do we enable PyMongo to read from the nearest? This field db.read_preference is read-only now. from pymongo import ReplicaSetConnection from pymongo import ReadPreference db = ReplicaSetConnection('localhost:27017', replicaSet='rs1')['my_db'] db.read_preference = ReadPreference.NEAREST db.tag_sets = [{'secondaries': 1}]

VIEW QUESTION
Back To Top
Search