當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。