Exemplo n.º 1
0
def update(database: str, table: str, register: dict, columns: list) -> int:
    try:
        retorno = 1
        db = __buscarLlaveBaseDato(database)
        if db is not None:
            modoDB = db[0]
            if modoDB == "avl":
                retorno = avl.update(database, table, register, columns)
            elif modoDB == "b":
                retorno = b.update(database, table, register, columns)
            elif modoDB == "bplus":
                retorno = bPlus.update(database, table, register, columns)
            elif modoDB == "dict":
                retorno = dic.update(database, table, register, columns)
            elif modoDB == "isam":
                retorno = isam.update(database, table, register, columns)
            elif modoDB == "json":
                retorno = json.update(database, table, register, columns)
            elif modoDB == "hash":
                retorno = hash.update(database, table, register, columns)
            return retorno
        else:
            return 2

    except Exception:
        return 1
Exemplo n.º 2
0
Arquivo: Bases.py Projeto: GleyP/Test
def update(database, table, register, columns):
    if searchInMode(database) != None:
        currentMode = searchInMode(database)
        if currentMode == 'avl':
            # avlList.append(tableNew)
            return avl.update(database, table, register, columns)
        elif currentMode == 'b':
            # bList.append(tableNew)
            return b.update(database, table, register, columns)
        elif currentMode == 'bplus':
            # bplusList.append(tableNew)
            return bplus.update(database, table, register, columns)
        elif currentMode == 'dict':
            # dictList.append(tableNew)
            return DM.update(database, table, register, columns)
        elif currentMode == 'isam':
            # isamList.append(tableNew)
            return isam.update(database, table, register, columns)
        elif currentMode == 'json':
            # jsonList.append(tableNew)
            return j.update(database, table, register, columns)
        elif currentMode == 'hash':
            # hashList.append(tableNew)
            return Hash.update(database, table, register, columns)
    else:
        return 2
Exemplo n.º 3
0
def update(database: str, table: str, register: dict, columns: list) -> int:
    """Updates a register into a table in a database

        Parameters:\n
            database (str): name of the database
            table (str): name of the table
            register (dict): key: column number, value: new values
            columns (list): PK of target register

        Returns:\n
            0: successful operation
            1: an error ocurred
            2: non-existent database
            3: non-existent table
            4: non-existent PK
    """

    bd = _database(database)

    if bd:

        tb = _table(database, table)

        if tb:

            mode = tb["modo"]

            val = -1

            if mode == "avl":
                val = avl.update(database, table, register, columns)

            elif mode == "b":
                val = b.update(database, table, register, columns)

            elif mode == "bplus":
                val = bplus.update(database, table, register, columns)

            elif mode == "hash":
                val = hash.update(database, table, register, columns)

            elif mode == "isam":
                val = isam.update(database, table, register, columns)

            elif mode == "json":
                val = json.update(database, table, register, columns)

            elif mode == "dict":
                val = dict.update(database, table, register, columns)

            return val

        else:
            return 3

    else:
        return 2
Exemplo n.º 4
0
def update(database, name_table, register, columns):
    ModeDB, indexDB = exist_Alter(database)
    if ModeDB:
        mode = ModeDB.get_mode()
        if mode.lower().strip() == "avl":
            return avl.update(database, name_table, register, columns)
        elif mode.lower().strip() == "b":
            return b.update(database, name_table, register, columns)
        elif mode.lower().strip() == "bPlus".lower():
            return bPlus.update(database, name_table, register, columns)
        elif mode.lower().strip() == "dict":
            return diccionario.update(database, name_table, register, columns)
        elif mode.lower().strip() == "hash":
            return hash.update(database, name_table, register, columns)
        elif mode.lower().strip() == "isam":
            return isam.update(database, name_table, register, columns)
        elif mode.lower().strip() == "json":
            return json.update(database, name_table, register, columns)