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)
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
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
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
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
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
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
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
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)
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