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


Python Db.activate方法代码示例

本文整理汇总了Python中db.Db.activate方法的典型用法代码示例。如果您正苦于以下问题:Python Db.activate方法的具体用法?Python Db.activate怎么用?Python Db.activate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在db.Db的用法示例。


在下文中一共展示了Db.activate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _makeIndex

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import activate [as 别名]
    def _makeIndex(self, table, pCols, iCols):
        selCols = ",".join(iCols)
        q = "SELECT %s FROM %s;" % (selCols, table)
        indexName = metadata.getIndexNameForTable(table)
        # might need to drop this table.

        # configure merger to drop ENGINE=MEMORY from merged table.
        config.config.set("resultdb","dropMem", "yes")
        # configure qserv to buffer in a big place
        #config.config.set("frontend", "scratch_path","/tmp/qsIndex")

        db = Db()
        db.activate()
        db.applySql("DROP TABLE IF EXISTS %s;" %(indexName)) #make room first.
        a = app.HintedQueryAction(q, {"db" : metadata.getMetaDbName()}, 
                                  self.pmap, 
                                  lambda e: None, indexName)
        
        assert a.getIsValid()
        print "Gathering objectId/chunkId locality from workers"
        print a.invoke() 
        print a.getResult()
        print "Retrieved result."
        for i in iCols:
            if i in pCols: continue
            print "creating index for", i
            iq = "ALTER TABLE %s ADD INDEX (%s);" % (indexName, i)
            print iq
            cids = db.applySql(iq)
            cids = map(lambda t: t[0], cids)
            del db
            print cids
开发者ID:lsst-dm,项目名称:legacy-qserv_master,代码行数:34,代码来源:indexing.py

示例2: tryCountQuery

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import activate [as 别名]
def tryCountQuery():
    tableName = "test.sanityTable"
    def clear(t):
        db = Db()
        db.activate()
        db.applySql("DROP TABLE IF EXISTS %s;" %(t))

    pmap = makePmap()
    q = "SELECT %s FROM %s %s;" % ("count(*)", "LSST.Object", "LIMIT 10")
    a = HintedQueryAction(q, 
                              {"db" : "test"},  # Use test db.
                              pmap, 
                              lambda e: None, tableName)
        
    assert a.getIsValid()
    a.chunkLimit = 6
    print "Trying q=",q
    clear(tableName)
    print a.invoke() 
    print a.getResult()
    db = Db()
    db.activate()
    db.applySql("select * from %s;" % tableName) #could print this

    clear(tableName)
开发者ID:lsst-dm,项目名称:legacy-qserv_master,代码行数:27,代码来源:testAppInterface.py

示例3: setupIndexes

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import activate [as 别名]
 def setupIndexes(self):
     p = PartitionGroup()
     db = Db()
     db.activate()
     db.makeIfNotExist(db=metadata.getMetaDbName())
     #logger.inf(p.tables)
     for (t,d) in p.tables.items():
         if d.has_key("index"):
             self._makeIndex(t, p.partitionCols, d["index"])
开发者ID:wangd,项目名称:qserv,代码行数:11,代码来源:indexing.py

示例4: clear

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import activate [as 别名]
 def clear(t):
     db = Db()
     db.activate()
     db.applySql("DROP TABLE IF EXISTS %s;" %(t))
开发者ID:lsst-dm,项目名称:legacy-qserv_master,代码行数:6,代码来源:testAppInterface.py


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