Exemple #1
0
def insertAlter(database, tabla, numberColumns, mode, listaDatos):
    if mode.lower().strip() == "avl":
        avl.createTable(database, tabla, numberColumns)
        for data in listaDatos:
            avl.insert(database, tabla, data)
    elif mode.lower().strip() == "b":
        b.createTable(database, tabla, numberColumns)
        for data in listaDatos:
            b.insert(database, tabla, data)
    elif mode.lower().strip() == "bPlus".lower():
        bPlus.createTable(database, tabla, numberColumns)
        for data in listaDatos:
            bPlus.insert(database, tabla, data)
    elif mode.lower().strip() == "dict":
        diccionario.createTable(database, tabla, numberColumns)
        for data in listaDatos:
            diccionario.insert(database, tabla, data)
    elif mode.lower().strip() == "isam":
        isam.createTable(database, tabla, numberColumns)
        for data in listaDatos:
            isam.insert(database, tabla, data)
    elif mode.lower().strip() == "hash":
        hash.createTable(database, tabla, numberColumns)
        for data in listaDatos:
            hash.insert(database, tabla, data)
    elif mode.lower().strip() == "json":
        json.createTable(database, tabla, numberColumns)
        for data in listaDatos:
            json.insert(database, tabla, data)
Exemple #2
0
def insert(database: str, table: str, register: list) -> int:
    try:
        retorno = 1
        codificacionOk = True
        db = __buscarLlaveBaseDato(database)
        if db is not None:
            modoDB = db[0]
            codificacionOk = code.verificaCodificacion(register, database)
            if codificacionOk is True:
                if modoDB == "avl":
                    retorno = avl.insert(database, table, register)
                elif modoDB == "b":
                    retorno = b.insert(database, table, register)
                elif modoDB == "bplus":
                    retorno = bPlus.insert(database, table, register)
                elif modoDB == "dict":
                    retorno = dic.insert(database, table, register)
                elif modoDB == "isam":
                    retorno = isam.insert(database, table, register)
                elif modoDB == "json":
                    retorno = json.insert(database, table, register)
                elif modoDB == "hash":
                    retorno = hash.insert(database, table, register)
                return retorno
            else:
                return 1
        else:
            return 2

    except Exception:
        return 1
Exemple #3
0
def __insert_sp(database: str, table: str, register: list, mode: str):
    dbs = databases.find_all(database)
    if dbs == []:
        return 2
    tb = databases.find_table(database, table)
    if tb == None:
        return 3
    if len(register) != tb.columns:
        return 5
    if mode not in MODES:
        return 6
    for db in dbs:
        if db.mode != mode:
            continue
        if db.mode == "avl":
            result = avlMode.insert(database, table, register)
        elif db.mode == "b":
            result = BMode.insert(database, table, register)
        elif db.mode == "bplus":
            result = BPlusMode.insert(database, table, register)
        elif db.mode == "dict":
            result = DictMode.insert(database, table, register)
        elif db.mode == "isam":
            result = ISAMMode.insert(database, table, register)
        elif db.mode == "json":
            result = jsonMode.insert(database, table, register)
        elif db.mode == "hash":
            result = HashMode.insert(database, table, register)
        else:
            continue
        if result != 3:
            break
    return result
Exemple #4
0
def insert(database, table, register):
    if searchInMode(database) != None:
        currentMode = searchInMode(database)
        if currentMode == 'avl':
            # avlList.append(tableNew)
            return avl.insert(database, table, register)
        elif currentMode == 'b':
            # bList.append(tableNew)
            return b.insert(database, table, register)
        elif currentMode == 'bplus':
            # bplusList.append(tableNew)
            return bplus.insert(database, table, register)
        elif currentMode == 'dict':
            # dictList.append(tableNew)
            return DM.insert(database, table, register)
        elif currentMode == 'isam':
            # isamList.append(tableNew)
            return isam.insert(database, table, register)
        elif currentMode == 'json':
            # jsonList.append(tableNew)
            return j.insert(database, table, register)
        elif currentMode == 'hash':
            # hashList.append(tableNew)
            return Hash.insert(database, table, register)
    else:
        return 2
Exemple #5
0
def insert(database: str, table: str, register: list):
    dbs = databases.find_all(database)
    if dbs == []:
        return 2
    for x in register:
        if type(x) == str and not verify_encoding(x, dbs[0].encoding):
            return 6
    for db in dbs:
        if db.mode == "avl":
            result = avlMode.insert(database, table, register)
        elif db.mode == "b":
            result = BMode.insert(database, table, register)
        elif db.mode == "bplus":
            result = BPlusMode.insert(database, table, register)
        elif db.mode == "dict":
            result = DictMode.insert(database, table, register)
        elif db.mode == "isam":
            result = ISAMMode.insert(database, table, register)
        elif db.mode == "json":
            result = jsonMode.insert(database, table, register)
        elif db.mode == "hash":
            result = HashMode.insert(database, table, register)
        if result != 3:
            break
    return result
Exemple #6
0
def insert(database, table, register):
    if saveModo_bandera is False:
        Block.activar_SaveModo(register)
        #print("validacion correcta")
    if searchInMode(database) != None:
        currentMode = searchInMode(database)
        if currentMode == 'avl':
            # avlList.append(tableNew)
            return avl.insert(database, table, register)
        elif currentMode == 'b':
            # bList.append(tableNew)
            return b.insert(database, table, register)
        elif currentMode == 'bplus':
            # bplusList.append(tableNew)
            return bplus.insert(database, table, register)
        elif currentMode == 'dict':
            # dictList.append(tableNew)
            return DM.insert(database, table, register)
        elif currentMode == 'isam':
            # isamList.append(tableNew)
            return isam.insert(database, table, register)
        elif currentMode == 'json':
            # jsonList.append(tableNew)
            return j.insert(database, table, register)
        elif currentMode == 'hash':
            # hashList.append(tableNew)
            return Hash.insert(database, table, register)
    else:
        return 2
Exemple #7
0
def insert(database: str, table: str, register: list) -> int:
    """Inserts a register into a table in a database

        Parameters:\n
            database (str): name of the database
            table (str): name of the table
            register (list): list with register values

        Returns:\n
            0: successful operation
            1: an error ocurred
            2: non-existent database
            3: non-existent table
            4: PK ocuppied
            5: register out of bounds
    """

    bd = _database(database)

    if bd:

        tb = _table(database, table)

        if tb:

            mode = tb["modo"]

            val = -1

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

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

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

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

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

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

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

            return val

        else:
            return 3

    else:
        return 2
Exemple #8
0
def insert(database, name_table, register):
    ModeDB, indexDB = exist_Alter(database)
    if ModeDB:
        mode = ModeDB.get_mode()
        if mode.lower().strip() == "avl":
            return avl.insert(database, name_table, register)
        elif mode.lower().strip() == "b":
            return b.insert(database, name_table, register)
        elif mode.lower().strip() == "bPlus".lower():
            return bPlus.insert(database, name_table, register)
        elif mode.lower().strip() == "dict":
            return diccionario.insert(database, name_table, register)
        elif mode.lower().strip() == "hash":
            return hash.insert(database, name_table, register)
        elif mode.lower().strip() == "isam":
            return isam.insert(database, name_table, register)
        elif mode.lower().strip() == "json":
            return json.insert(database, name_table, register)
Exemple #9
0
def insert(database: str, table: str, register: list):
    dbs = databases.find_all(database)
    if dbs == []:
        return 2
    for db in dbs:
        if db.mode == "avl":
            result = avlMode.insert(database, table, register)
        elif db.mode == "b":
            result = BMode.insert(database, table, register)
        elif db.mode == "bplus":
            result = BPlusMode.insert(database, table, register)
        elif db.mode == "dict":
            result = DictMode.insert(database, table, register)
        elif db.mode == "isam":
            result = ISAMMode.insert(database, table, register)
        elif db.mode == "json":
            result = jsonMode.insert(database, table, register)
        elif db.mode == "hash":
            result = HashMode.insert(database, table, register)
        if result != 3:
            break
    return result