Пример #1
0
def extractTable(database: str, table: str) -> list:
    try:
        retorno = []
        db = __buscarLlaveBaseDato(database)
        modoDB = db[0]
        if db is not None:
            tablas = db[2]
            if tablas:
                if tablas.get(table) is not None:
                    modoDB = tablas[table]

            if modoDB == "avl":
                retorno = avl.extractTable(database, table)
            elif modoDB == "b":
                retorno = b.extractTable(database, table)
            elif modoDB == "bplus":
                retorno = bPlus.extractTable(database, table)
            elif modoDB == "dict":
                retorno = dic.extractTable(database, table)
            elif modoDB == "isam":
                retorno = isam.extractTable(database, table)
            elif modoDB == "json":
                retorno = json.extractTable(database, table)
            elif modoDB == "hash":
                retorno = hash.extractTable(database, table)
            return retorno
        else:
            return None

    except Exception:
        return None
Пример #2
0
def extractTable(database, table):
    if searchInMode(database) != None:
        currentMode = searchInMode(database)
        if currentMode == 'avl':
            # avlList.append(tableNew)
            return avl.extractTable(database, table)
        elif currentMode == 'b':
            # bList.append(tableNew)
            return b.extractTable(database, table)
        elif currentMode == 'bplus':
            # bplusList.append(tableNew)
            return bplus.extractTable(database, table)
        elif currentMode == 'dict':
            # dictList.append(tableNew)
            return DM.extractTable(database, table)
        elif currentMode == 'isam':
            # isamList.append(tableNew)
            return isam.extractTable(database, table)
        elif currentMode == 'json':
            # jsonList.append(tableNew)
            return j.extractTable(database, table)
        elif currentMode == 'hash':
            # hashList.append(tableNew)
            return Hash.extractTable(database, table)
    else:
        return 2
Пример #3
0
def extractTable(database, table):
    dbs = databases.find_all(database)
    if dbs == []:
        return None
    if databases.find_table(database, table) == None:
        return None
    result = []
    for db in dbs:
        tb = db.tables.search(table)
        if tb != None:
            if db.mode == "avl":
                result = avlMode.extractTable(database, table)
            elif db.mode == "b":
                result = BMode.extractTable(database, table)
            elif db.mode == "bplus":
                result = BPlusMode.extractTable(database, table)
            elif db.mode == "dict":
                result = DictMode.extractTable(database, table)
            elif db.mode == "isam":
                result = ISAMMode.extractTable(database, table)
            elif db.mode == "json":
                result = jsonMode.extractTable(database, table)
            elif db.mode == "hash":
                result = HashMode.extractTable(database, table)
            else:
                continue
    return result
Пример #4
0
def extractTable(database: str, table: str) -> list:
    """Shows the content of a table in a database

        Parameters:\n
            database (str): name of the database
            table (str): name of the table

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

    bd = _database(database)

    if bd:

        tb = _table(database, table)

        if tb:

            mode = tb["modo"]

            val = -1

            if mode == "avl":
                val = avl.extractTable(database, table)

            elif mode == "b":
                val = b.extractTable(database, table)

            elif mode == "bplus":
                val = bplus.extractTable(database, table)

            elif mode == "hash":
                val = hash.extractTable(database, table)

            elif mode == "isam":
                val = isam.extractTable(database, table)

            elif mode == "json":
                val = json.extractTable(database, table)

            elif mode == "dict":
                val = dict.extractTable(database, table)

            return val

        else:
            return 3

    else:
        return 2
Пример #5
0
def get_Data(database: str, table: str, mode: str):
    if mode.lower().strip() == "avl":
        return avl.extractTable(database, table)
    elif mode.lower().strip() == "b":
        return b.extractTable(database, table)
    elif mode.lower().strip() == "bPlus".lower():
        return bPlus.extractTable(database, table)
    elif mode.lower().strip() == "dict":
        return diccionario.extractTable(database, table)
    elif mode.lower().strip() == "isam":
        return isam.extractTable(database, table)
    elif mode.lower().strip() == "hash":
        return hash.extractTable(database, table)
    elif mode.lower().strip() == "json":
        return json.extractTable(database, table)
Пример #6
0
def extractTable(database, table):
    mode = None
    for i in range(7):
        mode = obtenerBase(database, i)
        if mode == []:
            continue
        else:
            if mode == 0:
                mode = "avl"
            elif mode == 1:
                mode = "b"
            elif mode == 2:
                mode = "bplus"
            elif mode == 3:
                mode = "dict"
            elif mode == 4:
                mode = "isam"
            elif mode == 5:
                mode = "json"
            elif mode == 6:
                mode = "hash"
            break
    if mode == None:
        return 2
    if mode == "avl":
        # Grupo 16
        val = avl_mode.extractTable(database, table)
    elif mode == "b":
        # Grupo 17
        val = b_mode.extractTable(database, table)
    elif mode == "bplus":
        # Grupo 18
        val = bplus_mode.extractTable(database, table)
    elif mode == "dict":
        # Auxiliar
        val = dict_mode.extractTable(database, table)
    elif mode == "isam":
        # Grupo 14
        val = isam_mode.extractTable(database, table)
    elif mode == "json":
        # Ingeniero
        val = json_mode.extractTable(database, table)
    elif mode == "hash":
        # Grupo 15
        val = hash_mode.extractTable(database, table)
    else:
        val = 3
    return val
Пример #7
0
def __extraerContenidoTabla(tabla: str, modoDB: str, database: str) -> list:
    retorno = None
    if modoDB == "avl":
        retorno = avl.extractTable(database, tabla)
    elif modoDB == "b":
        retorno = b.extractTable(database, tabla)
    elif modoDB == "bplus":
        retorno = bPlus.extractTable(database, tabla)
    elif modoDB == "dict":
        retorno = dic.extractTable(database, tabla)
    elif modoDB == "isam":
        retorno = isam.extractTable(database, tabla)
    elif modoDB == "json":
        retorno = json.extractTable(database, tabla)
    elif modoDB == "hash":
        retorno = hash.extractTable(database, tabla)
    return retorno
Пример #8
0
def obtenerContenidoTabla(database, table, estructura):
    val = []
    if estructura == 0:
        val = avl_mode.extractTable(database, table)
    elif estructura == 1:
        val = b_mode.extractTable(database, table)
    elif estructura == 2:
        val = bplus_mode.extractTable(database, table)
    elif estructura == 3:
        val = dict_mode.extractTable(database, table)
    elif estructura == 4:
        val = isam_mode.extractTable(database, table.lower())
    elif estructura == 5:
        val = json_mode.extractTable(database, table)
    elif estructura == 6:
        val = hash_mode.extractTable(database, table)
    if val == []:
        return ""
    contenido = ""
    for i in range(len(val)):
        contenido += str(val[i])
    return contenido