Example #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
Example #2
0
File: Bases.py Project: 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
Example #3
0
def update(database, table, register, columns):
    dbs = databases.find_all(database)
    if dbs == []:
        return 2
    if databases.find_table(database, table) == None:
        return 3
    for x in register.values():
        if type(x) == str and not verify_encoding(x, dbs[0].encoding):
            return 5
    result = 1
    for db in dbs:
        if db.tables.search(table) == None:
            continue
        if db.mode == "avl":
            result = avlMode.update(database, table, register, columns)
        elif db.mode == "b":
            result = BMode.update(database, table, register, columns)
        elif db.mode == "bplus":
            result = BPlusMode.update(database, table, register, columns)
        elif db.mode == "dict":
            result = DictMode.update(database, table, register, columns)
        elif db.mode == "isam":
            result = ISAMMode.update(database, table, register, columns)
        elif db.mode == "json":
            result = jsonMode.update(database, table, register, columns)
        elif db.mode == "hash":
            result = HashMode.update(database, table, register, columns)
    return result
Example #4
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
Example #5
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)
Example #6
0
def update(database, table, register, columns):
    db = databases.search(database)
    if db == None:
        return 2
    if db.mode == "avl":
        result = avlMode.update(database, table, register, columns)
    elif db.mode == "b":
        result = BMode.update(database, table, register, columns)
    elif db.mode == "bplus":
        result = BPlusMode.update(database, table, register, columns)
    elif db.mode == "dict":
        result = DictMode.update(database, table, register, columns)
    elif db.mode == "isam":
        result = ISAMMode.update(database, table, register, columns)
    elif db.mode == "json":
        result = jsonMode.update(database, table, register, columns)
    elif db.mode == "hash":
        result = HashMode.update(database, table, register, columns)
    return result