def alterAddColumn(database: str, table: str, default: any) -> 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.alterAddColumn(database, table, default) elif modoDB == "b": retorno = b.alterAddColumn(database, table, default) elif modoDB == "bplus": retorno = bPlus.alterAddColumn(database, table, default) elif modoDB == "dict": retorno = dic.alterAddColumn(database, table, default) elif modoDB == "isam": retorno = isam.alterAddColumn(database, table, default) elif modoDB == "json": retorno = json.alterAddColumn(database, table, default) elif modoDB == "hash": retorno = hash.alterAddColumn(database, table, default) return retorno else: return 2 except Exception: return 1
def alterAddColumn(database, table, default): if searchInMode(database) != None: currentMode = searchInMode(database) if currentMode == 'avl': # avlList.append(tableNew) return avl.alterAddColumn(database, table, default) elif currentMode == 'b': # bList.append(tableNew) return b.alterAddColumn(database, table, default) elif currentMode == 'bplus': # bplusList.append(tableNew) return bplus.alterAddColumn(database, table, default) elif currentMode == 'dict': # dictList.append(tableNew) return DM.alterAddColumn(database, table, default) elif currentMode == 'isam': # isamList.append(tableNew) return isam.alterAddColumn(database, table, default) elif currentMode == 'json': # jsonList.append(tableNew) return j.alterAddColumn(database, table, default) elif currentMode == 'hash': # hashList.append(tableNew) return Hash.alterAddColumn(database, table, default) else: return 2
def alterAddColumn(database: str, table: str, default: any) -> int: dbs = databases.find_all(database) if dbs == []: return 2 for db in dbs: if db.mode == "avl": result = avlMode.alterAddColumn(database, table, default) elif db.mode == "b": result = BMode.alterAddColumn(database, table, default) elif db.mode == "bplus": result = BPlusMode.alterAddColumn(database, table, default) elif db.mode == "dict": result = DictMode.alterAddColumn(database, table, default) elif db.mode == "isam": result = ISAMMode.alterAddColumn(database, table, default) elif db.mode == "json": result = jsonMode.alterAddColumn(database, table, default) elif db.mode == "hash": result = HashMode.alterAddColumn(database, table, default) if result != 3: if result == 0: db.search(table).columns += 1 for x in range(5): try: Serializable.commit(databases, "lista_bases_de_datos") return result except: break return 1 break return result
def alterAddColumn(database: str, table: str, default: any) -> int: """Appends a column to a table in a database Parameters:\n database (str): name of the database table (str): name of the table default (any): default value of registers new column 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.alterAddColumn(database, table, default) elif mode == "b": val = b.alterAddColumn(database, table, default) elif mode == "bplus": val = bplus.alterAddColumn(database, table, default) elif mode == "hash": val = hash.alterAddColumn(database, table, default) elif mode == "isam": val = isam.alterAddColumn(database, table, default) elif mode == "json": val = json.alterAddColumn(database, table, default) elif mode == "dict": val = dict.alterAddColumn(database, table, default) if val == 0: _table(database, table)["columnas"]+=1 _Guardar() return val else: return 3 else: return 2
def alterAddColumn(database, name_table, default): ModeDB, indexDB = exist_Alter(database) if ModeDB: mode = ModeDB.get_mode() if mode.lower().strip() == "avl": return avl.alterAddColumn(database, name_table, default) elif mode.lower().strip() == "b": return b.alterAddColumn(database, name_table, default) elif mode.lower().strip() == "bPlus".lower(): return bPlus.alterAddColumn(database, name_table, default) elif mode.lower().strip() == "dict": return diccionario.alterAddColumn(database, name_table, default) elif mode.lower().strip() == "hash": return hash.alterAddColumn(database, name_table, default) elif mode.lower().strip() == "isam": return isam.alterAddColumn(database, name_table, default) elif mode.lower().strip() == "json": return json.alterAddColumn(database, name_table, default)