示例#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)
示例#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
示例#3
0
文件: Bases.py 项目: GleyP/Test
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
示例#4
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
示例#5
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
示例#6
0
文件: app.py 项目: cesargp45/tytus
def insert(database, table, register):
    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.insert(database, table, register)
    elif mode == "b":
        # Grupo 17
        val = b_mode.insert(database, table, register)
    elif mode == "bplus":
        # Grupo 18
        val = bplus_mode.insert(database, table, register)
    elif mode == "dict":
        # Auxiliar
        val = dict_mode.insert(database, table, register)
    elif mode == "isam":
        # Grupo 14
        val = isam_mode.insert(database, table, register)
    elif mode == "json":
        # Ingeniero
        val = json_mode.insert(database, table, register)
    elif mode == "hash":
        # Grupo 15
        val = hash_mode.insert(database, table, register)
    else:
        val = 3
    return val
示例#7
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)