def set_read_preference(db): if pymongo.version >= "2.1": db.read_preference = pymongo.ReadPreference.SECONDARY