當前位置: 首頁>>代碼示例>>Python>>正文


Python db.DbAccess類代碼示例

本文整理匯總了Python中hgu.db.DbAccess的典型用法代碼示例。如果您正苦於以下問題:Python DbAccess類的具體用法?Python DbAccess怎麽用?Python DbAccess使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DbAccess類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: insert

    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,代碼行數:28,代碼來源:DbRecord.py

示例2: getByOid

def getByOid(nodeOid):
    """
    Return the NODE DB record with the given OID.
    """

    return AnaNodeDbRecord(DbAccess.selectOne(
        _table, where = OID_COLUMN + " = " + DbAccess.formatSqlValue(nodeOid)))
開發者ID:ma-tech,項目名稱:Anatomy,代碼行數:7,代碼來源:AnaNodeDb.py

示例3: getByOid

def getByOid(exprOid):
    """
    Return the ISH_EXPRESSION DB record with the given OID.
    """

    return IshExpressionDbRecord(DbAccess.selectOne(
        _table, where = OID_COLUMN + " = " + DbAccess.formatSqlValue(exprOid)))
開發者ID:ma-tech,項目名稱:Anatomy,代碼行數:7,代碼來源:IshExpressionDb.py

示例4: getByAncestorOid

def getByAncestorOid(ancestorOid, relType = Relationships.PART_OF):
    """
    Return the all records with given OID as ancestor.
    """

    if relType != Relationships.PART_OF:
        # Take this error check out if and when we support transitive
        # closure of other relationship types.
        Util.fatalError([
            "AnadRelationshipTransitive.getByAncestorOid() currently only",
            "works with " + Relationships.PART_OF + " relationships."])

    ancestorIter = Iterator(
        where = (
            ANCESTOR_OID_COLUMN + " = " +
            DbAccess.formatSqlValue(ancestorOid) +
            " and " +
            RELATIONSHIP_TYPE_NAME_COLUMN + " = " +
            DbAccess.formatSqlValue(relType)))

    rels = []

    for dbRec in ancestorIter:
        rels.append(dbRec)

    return rels
開發者ID:ma-tech,項目名稱:Anatomy,代碼行數:26,代碼來源:AnadRelationshipTransitiveDb.py

示例5: deleteAll

    def deleteAll(self):
        """
        Delete every record in the table.
        """
        delete = "delete from " + self.getName() + ";"
        DbAccess.writeSql(delete)

        return
開發者ID:ma-tech,項目名稱:Anatomy,代碼行數:8,代碼來源:DbTable.py

示例6: getBySubmissionOid

def getBySubmissionOid(subOid):
    """
    Returns the probe record with the given submission OID, or None, if
    record does not exit.  Throws exception if more than one record exists.
    """

    sqlOid = DbAccess.formatSqlValue(subOid)
    return IshProbeDbRecord(DbAccess.selectOne(
        _table, SUBMISSION_OID_COLUMN + " = " + sqlOid))
開發者ID:ma-tech,項目名稱:Anatomy,代碼行數:9,代碼來源:IshProbeDb.py

示例7: getByOid

def getByOid(apoOid):
    """
    Return the AND_PART_OF record with the given OID.  Returns None
    if no record with that OID exists.
    """
    where = (
        "where " + OID_COLUMN + " = " + DbAccess.formatSqlValue(apoOid))

    return DbAccess.selectOne(_table, where)
開發者ID:ma-tech,項目名稱:Anatomy,代碼行數:9,代碼來源:AnadPartOfDb.py

示例8: getByOid

def getByOid(oid):
    """
    Returns the submission record with the given OID, or None, if
    record does not exit.  Throws exception if more than one record exists.
    """

    sqlOid = DbAccess.formatSqlValue(oid)
    return IshSubmissionDbRecord(DbAccess.selectOne(
        _table, OID_COLUMN + " = " + sqlOid))
開發者ID:ma-tech,項目名稱:Anatomy,代碼行數:9,代碼來源:IshSubmissionDb.py

示例9: getByOid

def getByOid(oid):
    """
    Returns the sample row with the given OID, 
     or None, if row does not exist.
      Throws exception if more than one record exists.
    """

    sqlOid = DbAccess.formatSqlValue(oid)
    return MicSeriesDbRecord(DbAccess.selectOne(
        _table, OID_COLUMN + " = " + sqlOid))
開發者ID:ma-tech,項目名稱:Anatomy,代碼行數:10,代碼來源:MicSeriesDb.py

示例10: getBySubFk

def getBySubFk(subfk):
    """
    Returns the sample row with the given Sub ID (FK), 
     or None, if row does not exist.
      Throws exception if more than one record exists.
    """

    sqlSubFk = DbAccess.formatSqlValue(subfk)
    return MicSampleDbRecord(DbAccess.selectOne(
        _table, SUB_FK + " = " + sqlSubFk))
開發者ID:ma-tech,項目名稱:Anatomy,代碼行數:10,代碼來源:MicSampleDb.py

示例11: getByFileName

def getByFileName(fname):
    """
    Returns the sample row with the given File Name,
     or None, if row does not exist.
      Throws exception if more than one record exists.
    """

    sqlFname = DbAccess.formatSqlValue(fname)
    return MicSampleDbRecord(DbAccess.selectOne(
        _table, FILE_NAME_COLUMN + " = " + sqlFname))
開發者ID:ma-tech,項目名稱:Anatomy,代碼行數:10,代碼來源:MicSampleDb.py

示例12: getByOid

def getByOid(timedNodeOid):
    """
    Return the TIMED NODE DB record with the given OID.
    """

    dbRecord = DbAccess.selectOne(
        _table, where = OID_COLUMN + " = " + DbAccess.formatSqlValue(timedNodeOid))
    if dbRecord:
        return AnaTimedNodeDbRecord(dbRecord)
    else:
        return None
開發者ID:ma-tech,項目名稱:Anatomy,代碼行數:11,代碼來源:AnaTimedNodeDb.py

示例13: getByDisplayId

def getByDisplayId(timedDisplayId):
    """
    Return the TIMED NODE DB record with the given display ID.
    """

    dbRecord = DbAccess.selectOne(
        _table, where = (DISPLAY_ID_COLUMN + " = " +
                         DbAccess.formatSqlValue(timedDisplayId)))
    if dbRecord:
        return AnaTimedNodeDbRecord(dbRecord)
    else:
        return None
開發者ID:ma-tech,項目名稱:Anatomy,代碼行數:12,代碼來源:AnaTimedNodeDb.py

示例14: getByLocalId

def getByLocalId(localId):
    """
    Returns the submission record with the given local ID, or None, if
    record does not exit.  Throws exception if more than one record exists.

    localId: The ID the submission had back when it was a submission in
             an EMAGE style local database.  (That is, when it was an XML
             file in a collection of XML files.)
    """

    sqlLocalId = DbAccess.formatSqlValue(localId)
    return IshSubmissionDbRecord(DbAccess.selectOne(
        _table, LOCAL_ID_COLUMN + " = " + sqlLocalId))
開發者ID:ma-tech,項目名稱:Anatomy,代碼行數:13,代碼來源:IshSubmissionDb.py

示例15: deleteAllBySubmissionOid

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,代碼行數:14,代碼來源:IshExpressionDb.py


注:本文中的hgu.db.DbAccess類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。