def dropTable(database, table): if searchInMode(table) != None: currentMode = searchInMode(table) if currentMode == 'avl': # avlList.append(tableNew) return avl.dropTable(database, table) elif currentMode == 'b': # bList.append(tableNew) return b.dropTable(database, table) elif currentMode == 'bplus': # bplusList.append(tableNew) return bplus.dropTable(database, table) elif currentMode == 'dict': # dictList.append(tableNew) return DM.dropTable(database, table) elif currentMode == 'isam': # isamList.append(tableNew) return isam.dropTable(database, table) elif currentMode == 'json': # jsonList.append(tableNew) return j.dropTable(database, table) elif currentMode == 'hash': # hashList.append(tableNew) return Hash.dropTable(database, table) else: return 2
def dropTable(database: str, table: str) -> int: try: retorno = 1 db = __buscarLlaveBaseDato(database) if db is not None: modoDB = db[0] tablas = db[2] if tablas: if tablas.get(table) is not None: modoDB = tablas[table] if modoDB == "avl": retorno = avl.dropTable(database, table) elif modoDB == "b": retorno = b.dropTable(database, table) elif modoDB == "bplus": retorno = bPlus.dropTable(database, table) elif modoDB == "dict": retorno = dic.dropTable(database, table) elif modoDB == "isam": retorno = isam.dropTable(database, table) elif modoDB == "json": retorno = json.dropTable(database, table) elif modoDB == "hash": retorno = hash.dropTable(database, table) return retorno else: return 2 except Exception: return 1
def __drop_table_sp(database, table, mode): dbs = databases.find_all(database) if dbs == []: return 2 if databases.find_table(database, table) == None: return 3 for db in dbs: if db.mode == mode == "avl": result = avlMode.dropTable(database, table) elif db.mode == mode == "b": result = BMode.dropTable(database, table) elif db.mode == mode == "bplus": result = BPlusMode.dropTable(database, table) elif db.mode == mode == "dict": result = DictMode.dropTable(database, table) elif db.mode == mode == "isam": result = ISAMMode.dropTable(database, table) elif db.mode == mode == "json": result = jsonMode.dropTable(database, table) elif db.mode == mode == "hash": result = HashMode.dropTable(database, table) else: continue if result != 3: if result == 0: db.tables.delete(table) for x in range(5): try: Serializable.commit(databases, "lista_bases_de_datos") return result except: break return 1 break return result
def dropTable(database: str, table: str) -> int: """Deletes a table in a database (including all of its content) Parameters:\n database (str): name of the database table (str): name of the table Returns:\n 0: successful operation 1: an error ocurred 2: non-existent database 3: non-existent table """ bd = _database(database) if bd: tb = _table(database, table) if tb: mode = tb["modo"] val = -1 if mode == "avl": val = avl.dropTable(database, table) elif mode == "b": val = b.dropTable(database, table) elif mode == "bplus": val = bplus.dropTable(database, table) elif mode == "hash": val = hash.dropTable(database, table) elif mode == "isam": val = isam.dropTable(database, table) elif mode == "json": val = json.dropTable(database, table) elif mode == "dict": val = dict.dropTable(database, table) if val == 0: _database(database)["tablas"].remove(_table(database, table)) _Guardar() return val else: return 3 else: return 2
def obtenerAtributosTabla(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.dropTable(database, table) elif mode == "b": # Grupo 17 val = b_mode.dropTable(database, table) elif mode == "bplus": # Grupo 18 val = bplus_mode.dropTable(database, table) elif mode == "dict": # Auxiliar val = dict_mode.dropTable(database, table) elif mode == "isam": # Grupo 14 val = isam_mode.dropTable(database, table) elif mode == "json": # Ingeniero val = json_mode.dropTable(database, table) elif mode == "hash": # Grupo 15 val = hash_mode.dropTable(database, table) else: val = 3 return val
def dropTable(database: str, table: str) -> int: """Deletes a table in a database (including all of its content) Parameters:\n database (str): name of the database table (str): name of the table Returns:\n 0: successful operation 1: an error ocurred 2: non-existent database 3: non-existent table """ bd = _Buscar(database) if bd: mode = bd[1] val = -1 if mode == "avl": val = avl.dropTable(database, table) elif mode == "b": val = b.dropTable(database, table) elif mode == "bplus": val = bplus.dropTable(database, table) elif mode == "hash": val = hash.dropTable(database, table) elif mode == "isam": val = isam.dropTable(database, table) elif mode == "json": val = json.dropTable(database, table) elif mode == "dict": val = dict.dropTable(database, table) return val else: return 2
def dropTable(database, name_table): ModeDB, indexDB = exist_Alter(database) if ModeDB: mode = ModeDB.get_mode() if mode.lower().strip() == "avl": return avl.dropTable(database, name_table) elif mode.lower().strip() == "b": return b.dropTable(database, name_table) elif mode.lower().strip() == "bPlus".lower(): return bPlus.dropTable(database, name_table) elif mode.lower().strip() == "dict": return diccionario.dropTable(database, name_table) elif mode.lower().strip() == "hash": return hash.dropTable(database, name_table) elif mode.lower().strip() == "isam": return isam.dropTable(database, name_table) elif mode.lower().strip() == "json": return json.dropTable(database, name_table)
def dropTable(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.dropTable(database, table) elif mode == "b": # Grupo 17 val = b_mode.dropTable(database, table) elif mode == "bplus": # Grupo 18 val = bplus_mode.dropTable(database, table) elif mode == "dict": # Auxiliar val = dict_mode.dropTable(database, table) elif mode == "isam": # Grupo 14 val = isam_mode.dropTable(database, table) elif mode == "json": # Ingeniero val = json_mode.dropTable(database, table) elif mode == "hash": # Grupo 15 val = hash_mode.dropTable(database, table) else: val = 3 if val == 0: global Tablas try: # Leemos el archivo binario de los registros de bases de datos fichero_lectura = open("TB_register", "rb") Tablas = pickle.load(fichero_lectura) Tablas[database].pop(table) if len(Tablas[database]) == 0: Tablas.pop(database) # Actualizamos el archivo binario de los registros de bases de datos fichero_escritura = open("TB_register", "wb") pickle.dump(Tablas, fichero_escritura) fichero_escritura.close() except: Tablas[database].pop(table) if len(Tablas[database]) == 0: Tablas.pop(database) # Actualizamos el archivo binario de los registros de bases de datos fichero_escritura = open("TB_register", "wb") pickle.dump(Tablas, fichero_escritura) fichero_escritura.close() return val
def alterTableMode(database: str, table: str, databaseRef: str, mode: str): if exist_Alter(database) and exist_Alter(databaseRef) and exist_Alter( databaseRef)[0].get_mode() == mode: ModeDB, indice = exist_Alter(database) if ModeDB: oldMode = ModeDB.get_mode() if oldMode.lower().strip() == "avl": tables = avl.showTables(database) for tabla in tables: if tabla == table: listaDatos = get_Data( database, tabla, oldMode) # UNA LISTA VACIA NO EJECUTA EL FOR numberColumns = len(listaDatos[0]) insertAlter(databaseRef, tabla, numberColumns, mode, listaDatos) avl.dropTable(database, table) elif oldMode.lower().strip() == "b": tables = b.showTables(database) for tabla in tables: if tabla == table: listaDatos = get_Data(database, tabla, oldMode) numberColumns = len(listaDatos[0]) insertAlter(databaseRef, tabla, numberColumns, mode, listaDatos) b.dropTable(database, table) elif oldMode.lower().strip() == "bPlus".lower(): tables = bPlus.showTables(database) for tabla in tables: if tabla == table: listaDatos = get_Data(database, tabla, oldMode) numberColumns = len(listaDatos[0]) insertAlter(databaseRef, tabla, numberColumns, mode, listaDatos) bPlus.dropTable(database, table) elif oldMode.lower().strip() == "dict": tables = diccionario.showTables(database) for tabla in tables: if tabla == table: listaDatos = get_Data(database, tabla, oldMode) numberColumns = len(listaDatos[0]) insertAlter(databaseRef, tabla, numberColumns, mode, listaDatos) diccionario.dropTable(database, table) elif oldMode.lower().strip() == "isam": tables = isam.showTables(database) for tabla in tables: if tabla == table: listaDatos = get_Data(database, tabla, oldMode) numberColumns = len(listaDatos[0]) insertAlter(databaseRef, tabla, numberColumns, mode, listaDatos) isam.dropTable(database, table) elif oldMode.lower().strip() == "hash": tables = hash.showTables(database) for tabla in tables: if tabla == table: listaDatos = get_Data(database, tabla, oldMode) numberColumns = len(listaDatos[0]) insertAlter(databaseRef, tabla, numberColumns, mode, listaDatos) hash.dropTable(database, table) elif oldMode.lower().strip() == "json": tables = json.showTables(database) for tabla in tables: if tabla == table: listaDatos = get_Data(database, tabla, oldMode) numberColumns = len(listaDatos[0]) insertAlter(databaseRef, tabla, numberColumns, mode, listaDatos) json.dropTable(database, table) else: return None