def deleteRecordById(aId): try: myerrors.checkInt(aId) cur = getCursor() query = QUERY_DELETE_ROW % aId cur.execute(query) cur.connection.commit() return cur.rowcount except: print "[Error]:"+dberr.DB_ERR_COULD_NOT_DELETE_RECORD raise
def getRowById(aId): try: myerrors.checkInt(aId) cur = getCursor() query = QUERY_GET_ROW_BY_ID + str(aId) cur.execute(query) rows = cur.fetchall() if len(rows) == 0: return record.recordDTO() if len(rows) > 1: raise RuntimeException("[Error]:"+dberr.DB_ERR_MORE_THAN_ONE_ROW_FOR_ID) dto = record.recordDTO() _setDTO(rows[0], dto) return dto except: print "[Error]:"+dberr.DB_ERR_COULD_NOT_FETCH_ROW_FROM_ID raise