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


Python DbAccess.writeSql方法代码示例

本文整理汇总了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
开发者ID:ma-tech,项目名称:Anatomy,代码行数:30,代码来源:DbRecord.py

示例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
开发者ID:ma-tech,项目名称:Anatomy,代码行数:10,代码来源:DbTable.py

示例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
开发者ID:ma-tech,项目名称:Anatomy,代码行数:16,代码来源:IshExpressionDb.py

示例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
开发者ID:ma-tech,项目名称:Anatomy,代码行数:38,代码来源:DbRecord.py

示例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
开发者ID:ma-tech,项目名称:Anatomy,代码行数:63,代码来源:RelationshipsTransitive.py


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