当前位置: 首页>>代码示例>>Python>>正文


Python ReplicaSetConnection.read_preference方法代码示例

本文整理汇总了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:
开发者ID:JohnCEarls,项目名称:trends,代码行数:33,代码来源:GEOvector.py

示例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']
开发者ID:liuct,项目名称:bugquery-lt,代码行数:8,代码来源:brstore.py

示例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
开发者ID:liuct,项目名称:bugquery-lt,代码行数:7,代码来源:brstore.py

示例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
开发者ID:liuct,项目名称:bugquery-lt,代码行数:8,代码来源:brconfig.py


注:本文中的pymongo.ReplicaSetConnection.read_preference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。