def alterDropColumn(database: str, table: str, columnNumber: int) -> 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.alterDropColumn(database, table, columnNumber) elif modoDB == "b": retorno = b.alterDropColumn(database, table, columnNumber) elif modoDB == "bplus": retorno = bPlus.alterDropColumn(database, table, columnNumber) elif modoDB == "dict": retorno = dic.alterDropColumn(database, table, columnNumber) elif modoDB == "isam": retorno = isam.alterDropColumn(database, table, columnNumber) elif modoDB == "json": retorno = json.alterDropColumn(database, table, columnNumber) elif modoDB == "hash": retorno = hash.alterDropColumn(database, table, columnNumber) return retorno else: return 2 except Exception: return 1
def alterDropColumn(database, table, columnNumber): if searchInMode(database) != None: currentMode = searchInMode(database) if currentMode == 'avl': # avlList.append(tableNew) return avl.alterDropColumn(database, table, columnNumber) elif currentMode == 'b': # bList.append(tableNew) return b.alterDropColumn(database, table, columnNumber) elif currentMode == 'bplus': # bplusList.append(tableNew) return bplus.alterDropColumn(database, table, columnNumber) elif currentMode == 'dict': # dictList.append(tableNew) return DM.alterDropColumn(database, table, columnNumber) elif currentMode == 'isam': # isamList.append(tableNew) return isam.alterDropColumn(database, table, columnNumber) elif currentMode == 'json': # jsonList.append(tableNew) return j.alterDropColumn(database, table, columnNumber) elif currentMode == 'hash': # hashList.append(tableNew) return Hash.alterDropColumn(database, table, columnNumber) else: return 2
def alterDropColumn(database: str, table: str, columnNumber: int) -> int: """Deletes a column of a table in a database Parameters:\n database (str): name of the database table (str): name of the table columnNumber (int): target column index Returns:\n 0: successful operation 1: an error ocurred 2: non-existent database 3: non-existent table 4: column cannot be deleted 5: column index out of bounds """ bd = _Buscar(database) if bd: mode = bd[1] val = -1 if mode == "avl": val = avl.alterDropColumn(database, table, columnNumber) elif mode == "b": val = b.alterDropColumn(database, table, columnNumber) elif mode == "bplus": val = bplus.alterDropColumn(database, table, columnNumber) elif mode == "hash": val = hash.alterDropColumn(database, table, columnNumber) elif mode == "isam": val = isam.alterDropColumn(database, table, columnNumber) elif mode == "json": val = json.alterDropColumn(database, table, columnNumber) elif mode == "dict": val = dict.alterDropColumn(database, table, columnNumber) return val else: return 2
def alterDropColumn(database, name_table, number_column): ModeDB, indexDB = exist_Alter(database) if ModeDB: mode = ModeDB.get_mode() if mode.lower().strip() == "avl": return avl.alterDropColumn(database, name_table, number_column) elif mode.lower().strip() == "b": return b.alterDropColumn(database, name_table, number_column) elif mode.lower().strip() == "bPlus".lower(): return bPlus.alterDropColumn(database, name_table, number_column) elif mode.lower().strip() == "dict": return diccionario.alterDropColumn(database, name_table, number_column) elif mode.lower().strip() == "hash": return hash.alterDropColumn(database, name_table, number_column) elif mode.lower().strip() == "isam": return isam.alterDropColumn(database, name_table, number_column) elif mode.lower().strip() == "json": return json.alterDropColumn(database, name_table, number_column)