Esempio n. 1
0
File: Bases.py Progetto: GleyP/Test
def extractRangeTable(database, table, columnNumber, lower, upper):
    if searchInMode(database) != None:
        currentMode = searchInMode(database)
        if currentMode == 'avl':
            # avlList.append(tableNew)
            return avl.extractRangeTable(database, table, columnNumber, lower,
                                         upper)
        elif currentMode == 'b':
            # bList.append(tableNew)
            return b.extractRangeTable(database, table, columnNumber, lower,
                                       upper)
        elif currentMode == 'bplus':
            # bplusList.append(tableNew)
            return bplus.extractRangeTable(database, table, columnNumber,
                                           lower, upper)
        elif currentMode == 'dict':
            # dictList.append(tableNew)
            return DM.extractRangeTable(database, table, columnNumber, lower,
                                        upper)
        elif currentMode == 'isam':
            # isamList.append(tableNew)
            return isam.extractRangeTable(database, table, columnNumber, lower,
                                          upper)
        elif currentMode == 'json':
            # jsonList.append(tableNew)
            return j.extractRangeTable(database, table, lower, upper)
        elif currentMode == 'hash':
            # hashList.append(tableNew)
            return Hash.extractRangeTable(database, table, columnNumber, lower,
                                          upper)
    else:
        return 2
Esempio n. 2
0
def extractRangeTable(database: str, table: str, columnNumber: int, lower: any,
                      upper: any) -> list:
    db = databases.search(database)
    if db == None:
        return None
    if db.mode == "avl":
        result = avlMode.extractRangeTable(database, table, columnNumber,
                                           lower, upper)
    elif db.mode == "b":
        result = BMode.extractRangeTable(database, table, columnNumber, lower,
                                         upper)
    elif db.mode == "bplus":
        result = BPlusMode.extractRangeTable(database, table, columnNumber,
                                             lower, upper)
    elif db.mode == "dict":
        result = DictMode.extractRangeTable(database, table, columnNumber,
                                            lower, upper)
    elif db.mode == "isam":
        result = ISAMMode.extractRangeTable(database, table, columnNumber,
                                            lower, upper)
    elif db.mode == "json":
        result = jsonMode.extractRangeTable(database, table, columnNumber,
                                            lower, upper)
    elif db.mode == "hash":
        result = HashMode.extractRangeTable(database, table, columnNumber,
                                            lower, upper)
    return result
Esempio n. 3
0
def extractRangeTable(database: str, table: str, columnNumber: int, lower: any,
                      upper: any) -> list:
    dbs = databases.find_all(database)
    if dbs == []:
        return None
    if databases.find_table(database, table) == None:
        return None

    registers = []
    for db in dbs:
        if db.tables.search(table) == None:
            continue
        if db.mode == "avl":
            registers = avlMode.extractRangeTable(database, table,
                                                  columnNumber, lower, upper)
        elif db.mode == "b":
            registers = BMode.extractRangeTable(database, table, columnNumber,
                                                lower, upper)
        elif db.mode == "bplus":
            registers = BPlusMode.extractRangeTable(database, table,
                                                    columnNumber, lower, upper)
        elif db.mode == "dict":
            registers = DictMode.extractRangeTable(database, table,
                                                   columnNumber, lower, upper)
        elif db.mode == "isam":
            registers = ISAMMode.extractRangeTable(database, table,
                                                   columnNumber, lower, upper)
        elif db.mode == "json":
            registers = jsonMode.extractRangeTable(database, table,
                                                   columnNumber, lower, upper)
        elif db.mode == "hash":
            registers = HashMode.extractRangeTable(database, table,
                                                   columnNumber, lower, upper)
    return registers
Esempio n. 4
0
def extractRangeTable(database: str, table: str, columnNumber: int, lower: any,
                      upper: any) -> list:
    """Shows the content whitin a range of a table in a database

        Parameters:\n
            database (str): name of the database
            table (str): name of the table
            columnNumber (int): PK to compare
            lower (any): lower limit of PK value
            upper (any): upper limit of PK value

        Returns:\n
            list: successful operation
            None: non-existent database, non-existent table, an error ocurred
    """

    bd = _Buscar(database)

    if bd:

        mode = bd[1]

        val = -1

        if mode == "avl":
            val = avl.extractRangeTable(database, table, columnNumber, lower,
                                        upper)

        elif mode == "b":
            val = b.extractRangeTable(database, table, columnNumber, lower,
                                      upper)

        elif mode == "bplus":
            val = bplus.extractRangeTable(database, table, columnNumber, lower,
                                          upper)

        elif mode == "hash":
            val = hash.extractRangeTable(database, table, columnNumber, lower,
                                         upper)

        elif mode == "isam":
            val = isam.extractRangeTable(database, table, columnNumber, lower,
                                         upper)

        elif mode == "json":
            val = json.extractRangeTable(database, table, columnNumber, lower,
                                         upper)

        elif mode == "dict":
            val = dict.extractRangeTable(database, table, columnNumber, lower,
                                         upper)

        return val

    else:
        return 2
Esempio n. 5
0
def extractRangeTable(database: str, table: str, columnNumber: int, lower: any, upper: any) -> list:
    try:
        retorno = []
        db = __buscarLlaveBaseDato(database)
        if db is not None:
            modoDB = db[0]
            tablas = db[2]
            if tablas:
                if tablas.get(table) is not None:
                    modoDB = tablas[table]
            if modoDB == "avl":
                retorno = avl.extractRangeTable(
                    database,
                    table,
                    columnNumber,
                    lower,
                    upper
                    )
            elif modoDB == "b":
                retorno = b.extractRangeTable(
                    database,
                    table,
                    columnNumber,
                    lower,
                    upper
                    )
            elif modoDB == "bplus":
                retorno = bPlus.extractRangeTable(
                    database,
                    table,
                    columnNumber,
                    lower,
                    upper
                    )
            elif modoDB == "dict":
                retorno = dic.extractRangeTable(
                    database,
                    table,
                    columnNumber,
                    lower,
                    upper
                    )
            elif modoDB == "isam":
                retorno = isam.extractRangeTable(
                    database,
                    table,
                    columnNumber,
                    lower,
                    upper
                    )
            elif modoDB == "json":
                retorno = json.extractRangeTable(
                    database,
                    table,
                    columnNumber,
                    lower,
                    upper
                    )
            elif modoDB == "hash":
                retorno = hash.extractRangeTable(
                    database,
                    table,
                    columnNumber,
                    lower,
                    upper
                    )
            return retorno
        else:
            return None

    except Exception:
        return None