本文整理汇总了Python中hgu.db.DbAccess.writeSql方法的典型用法代码示例。如果您正苦于以下问题:Python DbAccess.writeSql方法的具体用法?Python DbAccess.writeSql怎么用?Python DbAccess.writeSql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hgu.db.DbAccess
的用法示例。
在下文中一共展示了DbAccess.writeSql方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: insert
# 需要导入模块: from hgu.db import DbAccess [as 别名]
# 或者: from hgu.db.DbAccess import writeSql [as 别名]
def insert(self):
"""
Generate SQL to insert this record into the database.
"""
# import here to avoid obscure circular import problem
from hgu.db import DbAccess
columnNames = None
columnValues = None
for name, value in self.__columnValues.items():
sqlValue = DbAccess.formatSqlValue(value)
if columnNames:
columnNames += ", " + name
columnValues += ", " + sqlValue
else:
columnNames = name
columnValues = sqlValue
query = """
insert into """ + self.getTableName() + """
( """ + columnNames + """ )
values
( """ + columnValues + """ );"""
DbAccess.writeSql(query)
return
示例2: deleteAll
# 需要导入模块: from hgu.db import DbAccess [as 别名]
# 或者: from hgu.db.DbAccess import writeSql [as 别名]
def deleteAll(self):
"""
Delete every record in the table.
"""
delete = "delete from " + self.getName() + ";"
DbAccess.writeSql(delete)
return
示例3: deleteAllBySubmissionOid
# 需要导入模块: from hgu.db import DbAccess [as 别名]
# 或者: from hgu.db.DbAccess import writeSql [as 别名]
def deleteAllBySubmissionOid(submissionOid):
"""
Delete all expression records for the given submission OID.
"""
# :TODO: Add delete support to DbAccess and/or DbTable so all caller has
# to provide is the where clause.
delete = (
"delete from " + TABLE_NAME +
" where " + SUBMISSION_OID_COLUMN + " = " +
DbAccess.formatSqlValue(submissionOid) + ";")
DbAccess.writeSql(delete)
return
示例4: update
# 需要导入模块: from hgu.db import DbAccess [as 别名]
# 或者: from hgu.db.DbAccess import writeSql [as 别名]
def update(self):
"""
Generate SQL to update this record in the databse. This
assumes that none of the primary key fields are being changed.
"""
# import here to avoid obscure circular import problem
from hgu.db import DbAccess
table = self.getTable()
# build where clause
whereList = []
for keyColumnName in table.getKeyColumnNames():
cond = (
keyColumnName + " = "+
DbAccess.formatSqlValue(self.getColumnValue(keyColumnName)))
whereList.append(cond)
whereClause = reduce(Util.commaConcat, whereList)
# build set clause
setList = []
for nonKeyColumnName in table.getNonKeyColumnNames():
assign = (
nonKeyColumnName + " = "+
DbAccess.formatSqlValue(self.getColumnValue(nonKeyColumnName)))
setList.append(assign)
setClause = reduce(Util.commaConcat, setList)
query = """
update """ + table.getName() + """
set """ + setClause + """
where """ + whereClause + """;"""
DbAccess.writeSql(query)
return
示例5: _createImmediateRelsWhereChild
# 需要导入模块: from hgu.db import DbAccess [as 别名]
# 或者: from hgu.db.DbAccess import writeSql [as 别名]
def _createImmediateRelsWhereChild(currentNode):
"""
Create transitive relationships for immeditate relationships where the
given node is the child.
"""
currentOid = currentNode.getOid()
# Add relationships from this node to its immediate parents
relsWithParents = Relationships.getByChildOidRelType(
currentOid, Relationships.PART_OF)
for parentRel in relsWithParents:
parentOid = parentRel.getParentOid()
if not exists(Relationships.PART_OF, descendentOid = currentOid,
ancestorOid = parentOid):
start, stop = Nodes.getStageWindowForNodeOid(currentOid)
DbAccess.writeSql("/* direct */")
createRelationshipTransitive(
Relationships.PART_OF, descendentOid = currentOid,
ancestorOid = parentOid)
# Add relationships based on its parents' already defined
# transitive relationships. Transitive relationships
# do not cross relationship types.
ancestorRels = _byDescendentOidRelType.get((parentOid,
Relationships.PART_OF))
if ancestorRels != None:
for ancestorRel in ancestorRels.itervalues():
ancestorOid = ancestorRel.getAncestorOid()
ancestor = Nodes.getByOid(ancestorOid)
if not exists(relType = Relationships.PART_OF,
descendentOid = currentOid,
ancestorOid = ancestorOid):
# if reltype is part-of then only generate a transitive
# relationship if the ancestor and this node overlap in time.
# Group ancestors sometimes do not overlap with their
# descendents.
ancestorStart, ancestorStop = (
Nodes.getStageWindowForNodeOid(ancestorOid))
if (start.getSequence() > ancestorStop.getSequence() or
stop.getSequence() < ancestorStart.getSequence()):
if not ancestor.isGroup():
# oops, supposed to be a group
Util.fatalError([
"Ancestor stage window does not overlap " +
"with descendent stage window and",
"ancestor is not a group.",
"Ancestor ID: " + ancestor.getPublicId() +
" Name: " + ancestor.getName(),
" Start-Stop: " + ancestorStart.getName() +
"-" + ancestorStop.getName(),
"Descendent ID: " + currentNode.getPublicId() +
" Name: " + currentNode.getName(),
" Start-Stop: " + start.getName() +
"-" + stop.getName()])
else:
DbAccess.writeSql("/* from ancestor */")
createRelationshipTransitive(Relationships.PART_OF,
descendentOid = currentOid,
ancestorOid = ancestorOid)
return