本文整理汇总了Python中db.Db.applySql方法的典型用法代码示例。如果您正苦于以下问题:Python Db.applySql方法的具体用法?Python Db.applySql怎么用?Python Db.applySql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.Db
的用法示例。
在下文中一共展示了Db.applySql方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _makeIndex
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import applySql [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
示例2: tryCountQuery
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import applySql [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)
示例3: clear
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import applySql [as 别名]
def clear(t):
db = Db()
db.activate()
db.applySql("DROP TABLE IF EXISTS %s;" %(t))