本文整理汇总了Python中CommonUtils.treeTableName方法的典型用法代码示例。如果您正苦于以下问题:Python CommonUtils.treeTableName方法的具体用法?Python CommonUtils.treeTableName怎么用?Python CommonUtils.treeTableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonUtils
的用法示例。
在下文中一共展示了CommonUtils.treeTableName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: import CommonUtils [as 别名]
# 或者: from CommonUtils import treeTableName [as 别名]
alltablelist.append(CommonUtils.commentTableName())
except ValueError:
pass
for tablename in tablelist:
posbeg=tablename.find('TAGTREE_TABLE_')
if posbeg != -1:
treename=tablename[posbeg+len('TAGTREE_TABLE_'):]
trees.append(treename)
for tree in trees:
try:
tablelist.index(CommonUtils.treeIDTableName(tree))
except ValueError:
print 'non-existing id table for tree ',tree
continue
alltablelist.append(CommonUtils.treeTableName(tree))
alltablelist.append(CommonUtils.treeIDTableName(tree))
#schema preparation
inv=tagInventory.tagInventory(self.__destsession)
inv.createInventoryTable()
for treename in trees:
t=TagTree.tagTree(self.__destsession,treename)
t.createTagTreeTable()
#copy table contents
try:
for mytable in alltablelist:
dest_transaction.start(False)
source_transaction.start(True)
data=coral.AttributeList()
my_editor=self.__destsession.nominalSchema().tableHandle(mytable).dataEditor()
source_query=self.__sourcesession.nominalSchema().tableHandle(mytable).newQuery()
示例2: copyTrees
# 需要导入模块: import CommonUtils [as 别名]
# 或者: from CommonUtils import treeTableName [as 别名]
def copyTrees( self, treenames ):
"""copy tree from an external source.
Merge inventory if existing in the destination
"""
allleafs=[]
for treename in treenames:
t=TagTree.tagTree(self.__sourcesession,treename)
allleafs.append(t.getAllLeaves())
#create a unique tag list
merged={}
for s in allleafs:
for x in s:
merged[x.tagid]=1
sourceinv=tagInventory.tagInventory(self.__sourcesession)
sourcetags=sourceinv.getAllEntries()
entries=[]
for i in merged.keys():
for n in sourcetags:
if n.tagid==i:
entry={}
entry['tagid']=i
entry['tagname']=n.tagname
entry['pfn']=n.pfn
entry['recordname']=n.recordname
entry['objectname']=n.objectname
entry['labelname']=n.labelname
entries.append(entry)
inv=tagInventory.tagInventory(self.__destsession)
tagiddict=inv.bulkInsertEntries(entries)
dest_transaction=self.__destsession.transaction()
source_transaction=self.__sourcesession.transaction()
#copy table contents
try:
for treename in treenames:
desttree=TagTree.tagTree(self.__destsession,treename)
desttree.createTagTreeTable()
dest_transaction.start(False)
source_transaction.start(True)
#copy tree tables
data=coral.AttributeList()
dest_editor=self.__destsession.nominalSchema().tableHandle(CommonUtils.treeTableName(treename)).dataEditor()
source_query=self.__sourcesession.nominalSchema().tableHandle(CommonUtils.treeTableName(treename)).newQuery()
conditionData=coral.AttributeList()
source_query.setCondition('',conditionData)
source_query.setRowCacheSize(self.__rowcachesize)
dest_editor.rowBuffer(data)
source_query.defineOutput(data)
bulkOperation=dest_editor.bulkInsert(data,self.__rowcachesize)
cursor=source_query.execute()
while cursor.next():
bulkOperation.processNextIteration()
bulkOperation.flush()
del bulkOperation
del source_query
#copy id tables
iddata=coral.AttributeList()
dest_editor=self.__destsession.nominalSchema().tableHandle(CommonUtils.treeIDTableName(treename)).dataEditor()
source_query=self.__sourcesession.nominalSchema().tableHandle(CommonUtils.treeIDTableName(treename)).newQuery()
conditionData=coral.AttributeList()
source_query.setCondition('',conditionData)
source_query.setRowCacheSize(self.__rowcachesize)
dest_editor.rowBuffer(iddata)
source_query.defineOutput(iddata)
bulkOperation=dest_editor.bulkInsert(iddata,self.__rowcachesize)
cursor=source_query.execute()
while cursor.next():
bulkOperation.processNextIteration()
bulkOperation.flush()
del bulkOperation
del source_query
#copy comment tables if exist
if self.__sourcesession.nominalSchema().existsTable(CommonUtils.commentTableName()):
data=coral.AttributeList()
dest_editor=self.__destsession.nominalSchema().tableHandle(CommonUtils.commentTableName()).dataEditor()
source_query=self.__sourcesession.nominalSchema().tableHandle(CommonUtils.commentTableName()).newQuery()
conditionData=coral.AttributeList()
source_query.setCondition('tablename = :tablename',conditionData)
conditionData.extend('tablename','string')
conditionData['tablename'].setData(CommonUtils.treeTableName(treename))
source_query.setRowCacheSize(self.__rowcachesize)
dest_editor.rowBuffer(data)
source_query.defineOutput(data)
bulkOperation=dest_editor.bulkInsert(data,self.__rowcachesize)
cursor=source_query.execute()
while cursor.next():
bulkOperation.processNextIteration()
bulkOperation.flush()
del bulkOperation
del source_query
source_transaction.commit()
dest_transaction.commit()
#fix leaf node links
desttree.replaceLeafLinks(tagiddict)
except Exception, e:
source_transaction.rollback()
dest_transaction.rollback()
raise Exception, str(e)
示例3: str
# 需要导入模块: import CommonUtils [as 别名]
# 或者: from CommonUtils import treeTableName [as 别名]
except Exception, e:
transaction.rollback()
raise Exception, str(e)
if __name__ == "__main__":
svc = coral.ConnectionService()
session = svc.connect( 'sqlite_file:testentryComment.db',
accessMode = coral.access_Update )
try:
entrycomment=entryComment(session)
print "test create entrycomment table"
entrycomment.createEntryCommentTable()
print "test insert one comment"
entrycomment.insertComment(CommonUtils.inventoryTableName(),12,'comment1')
entrycomment.insertComment(CommonUtils.treeTableName('ABCTREE'),12,'comment1')
print "test bulk insert"
bulkinput=[]
bulkinput.append({'entryid':21,'tablename':CommonUtils.inventoryTableName(),'comment':'mycomment'})
bulkinput.append({'entryid':22,'tablename':CommonUtils.inventoryTableName(),'comment':'mycomment2'})
bulkinput.append({'entryid':23,'tablename':CommonUtils.inventoryTableName(),'comment':'mycomment3'})
bulkinput.append({'entryid':24,'tablename':CommonUtils.inventoryTableName(),'comment':'mycomment4'})
entrycomment.bulkinsertComments(CommonUtils.inventoryTableName(),bulkinput)
print "test getCommentsForTable ",CommonUtils.inventoryTableName()
results=entrycomment.getCommentsForTable(CommonUtils.inventoryTableName())
print results
result=entrycomment.getCommentForId(CommonUtils.inventoryTableName(),23)
print result
entrycomment.modifyCommentForId(CommonUtils.inventoryTableName(),23, 'mynewcomment' )
print entrycomment.getCommentForId(CommonUtils.inventoryTableName(),23)
print 'test replaceid'