def extractTable(database: str, table: str) -> list: try: retorno = [] db = __buscarLlaveBaseDato(database) modoDB = db[0] if db is not None: tablas = db[2] if tablas: if tablas.get(table) is not None: modoDB = tablas[table] if modoDB == "avl": retorno = avl.extractTable(database, table) elif modoDB == "b": retorno = b.extractTable(database, table) elif modoDB == "bplus": retorno = bPlus.extractTable(database, table) elif modoDB == "dict": retorno = dic.extractTable(database, table) elif modoDB == "isam": retorno = isam.extractTable(database, table) elif modoDB == "json": retorno = json.extractTable(database, table) elif modoDB == "hash": retorno = hash.extractTable(database, table) return retorno else: return None except Exception: return None
def extractTable(database, table): if searchInMode(database) != None: currentMode = searchInMode(database) if currentMode == 'avl': # avlList.append(tableNew) return avl.extractTable(database, table) elif currentMode == 'b': # bList.append(tableNew) return b.extractTable(database, table) elif currentMode == 'bplus': # bplusList.append(tableNew) return bplus.extractTable(database, table) elif currentMode == 'dict': # dictList.append(tableNew) return DM.extractTable(database, table) elif currentMode == 'isam': # isamList.append(tableNew) return isam.extractTable(database, table) elif currentMode == 'json': # jsonList.append(tableNew) return j.extractTable(database, table) elif currentMode == 'hash': # hashList.append(tableNew) return Hash.extractTable(database, table) else: return 2
def extractTable(database, table): dbs = databases.find_all(database) if dbs == []: return None if databases.find_table(database, table) == None: return None result = [] for db in dbs: tb = db.tables.search(table) if tb != None: if db.mode == "avl": result = avlMode.extractTable(database, table) elif db.mode == "b": result = BMode.extractTable(database, table) elif db.mode == "bplus": result = BPlusMode.extractTable(database, table) elif db.mode == "dict": result = DictMode.extractTable(database, table) elif db.mode == "isam": result = ISAMMode.extractTable(database, table) elif db.mode == "json": result = jsonMode.extractTable(database, table) elif db.mode == "hash": result = HashMode.extractTable(database, table) else: continue return result
def checksumDatabase(database, mode: str): objet_mode, index = get_object_mode(database) if objet_mode is None: return None mode_db = objet_mode.get_mode() # sha256 -> 1 if mode.lower().strip() == "sha256": data = "" if mode_db.lower().strip() == "avl": data = avl.showTables(database) elif mode_db.lower().strip() == "b": data = list() for tables in b.showTables(database): data.append(b.extractTable(database, tables)) elif mode_db.lower().strip() == "bPlus".lower(): data = bPlus.showTables(database) elif mode_db.lower().strip() == "dict": data = diccionario.showTables(database) elif mode_db.lower().strip() == "hash": data = hash.showTables(database) elif mode_db.lower().strip() == "isam": data = isam.showTables(database) elif mode_db.lower().strip() == "json": data = json.showTables(database) return checksum_database(1, database, mode_db, data) # md5 -> 2 elif mode.lower().strip() == "md5": data = "" if mode_db.lower().strip() == "avl": data = avl.showTables(database) elif mode_db.lower().strip() == "b": data = list() for tables in b.showTables(database): data.append(b.extractTable(database, tables)) elif mode_db.lower().strip() == "bPlus".lower(): data = bPlus.showTables(database) elif mode_db.lower().strip() == "dict": data = diccionario.showTables(database) elif mode_db.lower().strip() == "hash": data = hash.showTables(database) elif mode_db.lower().strip() == "isam": data = isam.showTables(database) elif mode_db.lower().strip() == "json": data = json.showTables(database) return checksum_database(2, database, mode_db, data) else: return None
def extractTable(database: str, table: str) -> list: """Shows the content of a table in a database Parameters:\n database (str): name of the database table (str): name of the table Returns:\n list: successful operation None: non-existent database, non-existent table, an error ocurred """ bd = _database(database) if bd: tb = _table(database, table) if tb: mode = tb["modo"] val = -1 if mode == "avl": val = avl.extractTable(database, table) elif mode == "b": val = b.extractTable(database, table) elif mode == "bplus": val = bplus.extractTable(database, table) elif mode == "hash": val = hash.extractTable(database, table) elif mode == "isam": val = isam.extractTable(database, table) elif mode == "json": val = json.extractTable(database, table) elif mode == "dict": val = dict.extractTable(database, table) return val else: return 3 else: return 2
def get_Data(database: str, table: str, mode: str): if mode.lower().strip() == "avl": return avl.extractTable(database, table) elif mode.lower().strip() == "b": return b.extractTable(database, table) elif mode.lower().strip() == "bPlus".lower(): return bPlus.extractTable(database, table) elif mode.lower().strip() == "dict": return diccionario.extractTable(database, table) elif mode.lower().strip() == "isam": return isam.extractTable(database, table) elif mode.lower().strip() == "hash": return hash.extractTable(database, table) elif mode.lower().strip() == "json": return json.extractTable(database, table)
def extractTable(database, table): 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.extractTable(database, table) elif mode == "b": # Grupo 17 val = b_mode.extractTable(database, table) elif mode == "bplus": # Grupo 18 val = bplus_mode.extractTable(database, table) elif mode == "dict": # Auxiliar val = dict_mode.extractTable(database, table) elif mode == "isam": # Grupo 14 val = isam_mode.extractTable(database, table) elif mode == "json": # Ingeniero val = json_mode.extractTable(database, table) elif mode == "hash": # Grupo 15 val = hash_mode.extractTable(database, table) else: val = 3 return val
def __extraerContenidoTabla(tabla: str, modoDB: str, database: str) -> list: retorno = None if modoDB == "avl": retorno = avl.extractTable(database, tabla) elif modoDB == "b": retorno = b.extractTable(database, tabla) elif modoDB == "bplus": retorno = bPlus.extractTable(database, tabla) elif modoDB == "dict": retorno = dic.extractTable(database, tabla) elif modoDB == "isam": retorno = isam.extractTable(database, tabla) elif modoDB == "json": retorno = json.extractTable(database, tabla) elif modoDB == "hash": retorno = hash.extractTable(database, tabla) return retorno
def obtenerContenidoTabla(database, table, estructura): val = [] if estructura == 0: val = avl_mode.extractTable(database, table) elif estructura == 1: val = b_mode.extractTable(database, table) elif estructura == 2: val = bplus_mode.extractTable(database, table) elif estructura == 3: val = dict_mode.extractTable(database, table) elif estructura == 4: val = isam_mode.extractTable(database, table.lower()) elif estructura == 5: val = json_mode.extractTable(database, table) elif estructura == 6: val = hash_mode.extractTable(database, table) if val == []: return "" contenido = "" for i in range(len(val)): contenido += str(val[i]) return contenido
def checksumTable(database, table: str, mode: str): object_mode, index = get_object_mode(database) if object_mode: mode_db = object_mode.get_mode() if mode.lower().strip() == "sha256": data = "" if mode_db.lower().strip() == "avl": if table.strip() in avl.showTables(database): data = table else: return None elif mode_db.lower().strip() == "b": if table.strip() in b.showTables(database): data = b.extractTable(database, table) else: return None elif mode_db.lower().strip() == "bPlus".lower(): if table.strip() in bPlus.showTables(database): data = table else: return None elif mode_db.lower().strip() == "dict": if table.strip() in diccionario.showTables(database): data = table else: return None elif mode_db.lower().strip() == "hash": if table.strip() in hash.showTables(database): data = table else: return None elif mode_db.lower().strip() == "isam": if table.strip() in isam.showTables(database): data = table else: return None elif mode_db.lower().strip() == "json": if table.strip() in json.showTables(database): data = table else: return None return checksum_table(1, database, mode_db, data) elif mode.lower().strip() == "md5": data = "" if mode_db.lower().strip() == "avl": if table.strip() in avl.showTables(database): data = table else: return None elif mode_db.lower().strip() == "b": if table.strip() in b.showTables(database): data = b.extractTable(database, table) else: return None elif mode_db.lower().strip() == "bPlus".lower(): if table.strip() in bPlus.showTables(database): data = table else: return None elif mode_db.lower().strip() == "dict": if table.strip() in diccionario.showTables(database): data = table else: return None elif mode_db.lower().strip() == "hash": if table.strip() in hash.showTables(database): data = table else: return None elif mode_db.lower().strip() == "isam": if table.strip() in isam.showTables(database): data = table else: return None elif mode_db.lower().strip() == "json": if table.strip() in json.showTables(database): data = table else: return None return checksum_table(2, database, mode_db, data) else: return None else: return None