本文整理汇总了Python中pymongo.ReplicaSetConnection.read_preference方法的典型用法代码示例。如果您正苦于以下问题:Python ReplicaSetConnection.read_preference方法的具体用法?Python ReplicaSetConnection.read_preference怎么用?Python ReplicaSetConnection.read_preference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymongo.ReplicaSetConnection
的用法示例。
在下文中一共展示了ReplicaSetConnection.read_preference方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadGlobal
# 需要导入模块: from pymongo import ReplicaSetConnection [as 别名]
# 或者: from pymongo.ReplicaSetConnection import read_preference [as 别名]
@classmethod
def loadGlobal(cls, filename):
"""
Loads a previously created global_storage file
"""
import json
f = open(filename, 'r')
cls.global_storage = json.load(f)
f.close()
if __name__ == "__main__":
import json
from pymongo import ReplicaSetConnection, ReadPreference
connection = ReplicaSetConnection("clutch:27017", replicaSet="geo")
connection.read_preference = ReadPreference.SECONDARY
f = open("words.json",'r')
word_dict = json.loads(f.read())
f.close()
#GEOvector.loadGlobal("gv_test.json" )
gv = GEOvector('GSE2395',word_dict, mongo_conn=connection, cache=False)
print gv.getSparse()
print "1"
print sum(gv)
print sum(gv)
sadfjkl = raw_input('What is your name? ')
for x in gv:
示例2: getDB
# 需要导入模块: from pymongo import ReplicaSetConnection [as 别名]
# 或者: from pymongo.ReplicaSetConnection import read_preference [as 别名]
def getDB(self):
#return Connection('192.168.7.201',27017)['bugreporter']
#return Connection('localhost',27017)['bugreporter']
conn=ReplicaSetConnection("192.168.5.60:27017,192.168.7.52:27017,192.168.5.156:27017", replicaSet='ats_rs')
conn.read_preference = ReadPreference.SECONDARY_PREFERRED
return conn['bugreporter']
示例3: getConn
# 需要导入模块: from pymongo import ReplicaSetConnection [as 别名]
# 或者: from pymongo.ReplicaSetConnection import read_preference [as 别名]
def getConn(self):
#return Connection('192.168.7.201',27017)
conn=ReplicaSetConnection("192.168.5.60:27017,192.168.7.52:27017,192.168.5.156:27017", replicaSet='ats_rs')
conn.read_preference = ReadPreference.SECONDARY_PREFERRED
return conn
示例4: getMongoDB
# 需要导入模块: from pymongo import ReplicaSetConnection [as 别名]
# 或者: from pymongo.ReplicaSetConnection import read_preference [as 别名]
def getMongoDB():
conn=ReplicaSetConnection("192.168.5.60:27017,192.168.7.52:27017,192.168.5.156:27017", replicaSet='ats_rs')
conn.read_preference = ReadPreference.SECONDARY_PREFERRED
db = conn['bugreporter']
collection = db['original_data']
return collection