def alterDropPK(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.alterDropPK(database, table) elif modoDB == "b": retorno = b.alterDropPK(database, table) elif modoDB == "bplus": retorno = bPlus.alterDropPK(database, table) elif modoDB == "dict": retorno = dic.alterDropPK(database, table) elif modoDB == "isam": retorno = isam.alterDropPK(database, table) elif modoDB == "json": retorno = json.alterDropPK(database, table) elif modoDB == "hash": retorno = hash.alterDropPK(database, table) if retorno == 0: pk = generalDict[database][3] del pk[table] generalDict[database][3] = pk ser("data/info/datos.bin", generalDict) return retorno else: return 2 except Exception: return 1
def dropDatabase(database: str) -> int: try: retorno = 1 bd = __buscarLlaveBaseDato(database) if bd is not None: modoDB = bd[0] if modoDB == "avl": retorno = avl.dropDatabase(database) elif modoDB == "b": retorno = b.dropDatabase(database) elif modoDB == "bplus": retorno = bPlus.dropDatabase(database) elif modoDB == "dict": retorno = dic.dropDatabase(database) elif modoDB == "isam": retorno = isam.dropDatabase(database) elif modoDB == "json": retorno = json.dropDatabase(database) elif modoDB == "hash": retorno = hash.dropDatabase(database) if retorno == 0: del generalDict[database] ser("data/info/datos.bin", generalDict) return retorno else: return 2 except Exception: return 1
def alterDatabase(databaseOld, databaseNew) -> int: try: retorno = 2 if __buscarLlaveBaseDato(databaseNew) is None: db = __buscarLlaveBaseDato(databaseOld) if db is not None: modoDB = db[0] if modoDB == "avl": retorno = avl.alterDatabase(databaseOld, databaseNew) elif modoDB == "b": retorno = b.alterDatabase(databaseOld, databaseNew) elif modoDB == "bplus": retorno = bPlus.alterDatabase(databaseOld, databaseNew) elif modoDB == "dict": retorno = dic.alterDatabase(databaseOld, databaseNew) elif modoDB == "isam": retorno = isam.alterDatabase(databaseOld, databaseNew) elif modoDB == "json": retorno = json.alterDatabase(databaseOld, databaseNew) elif modoDB == "hash": retorno = hash.alterDatabase(databaseOld, databaseNew) if retorno == 0: generalDict[databaseNew] = generalDict[databaseOld] del generalDict[databaseOld] ser("data/info/datos.bin", generalDict) return retorno else: return 3 except Exception: return 1
def createDatabase(database: str, mode: str, encoding: str) -> int: try: retorno = 3 if encoding in ["ascii", "iso-8859-1", "utf8"]: if __buscarLlaveBaseDato(database) is None: if mode == "avl": retorno = avl.createDatabase(database) elif mode == "b": retorno = b.createDatabase(database) elif mode == "bplus": retorno = bPlus.createDatabase(database) elif mode == "dict": retorno = dic.createDatabase(database) elif mode == "isam": retorno = isam.createDatabase(database) elif mode == "json": retorno = json.createDatabase(database) elif mode == "hash": retorno = hash.createDatabase(database) else: retorno = 3 if retorno == 0: generalDict.setdefault(database, [mode, encoding, {}, {}]) ser("data/info/datos.bin", generalDict) return retorno else: return 2 else: return 4 except Exception: return 1
def alterTableMode(database: str, table: str, mode: str) -> int: try: retorno = 1 db = __buscarLlaveBaseDato(database) modeOld = db[0] if db is not None: tablasDiferentes = db[2] codificacion = db[1] if tablasDiferentes: if mode not in ["avl", "b", "bplus", "hash", "isam", "json", "dict"]: retorno = 4 if table in showTables(database): retorno = __CreaDatabaseInsertaDatosTabla(database, mode, modeOld, codificacion, table) else: tablaExiste = False for key in tablasDiferentes: if table == key: tablaExiste = True if tablaExiste == True: retorno = __CreaDatabaseInsertaDatosTabla(database, mode, modeOld, codificacion, table) else: retorno = 3 else: if mode not in ["avl", "b", "bplus", "hash", "isam", "json", "dict"]: return 4 if table in showTables(database): retorno = __CreaDatabaseInsertaDatosTabla(database, mode,modeOld, codificacion, table) else: retorno = 3 if retorno == 0: tablasDiferentes.setdefault(table, mode) db[2] = tablasDiferentes generalDict[database] = db ser("data/info/datos.bin", generalDict) return retorno else: return 2 except Exception: return 1
def alterDatabaseMode(database: str, mode: str) -> int: try: valor = 1 db = __buscarLlaveBaseDato(database) retorno = 1 if db is not None: modeOld = db[0] tablas = showTables(database) codificacion = db[1] if mode == "avl": retorno = avl.createDatabase(database) elif mode == "b": retorno = b.createDatabase(database) elif mode == "bplus": retorno = bPlus.createDatabase(database) elif mode == "dict": retorno = dic.createDatabase(database) elif mode == "isam": retorno = isam.createDatabase(database) elif mode == "json": retorno = json.createDatabase(database) elif mode == "hash": retorno = hash.createDatabase(database) else: retorno = 4 if retorno == 0 or retorno == 2: valor = __insertarDatosTablas(tablas, mode, modeOld, database, codificacion) retorno = valor dicc = db[2] if valor == 0: dropDatabase(database) db[0] = mode db[2] = {} generalDict[database] = db ser("data/info/datos.bin", generalDict) return retorno else: return 2 except Exception: return 1
def alterDatabaseEncoding(database: str, encoding: str) -> int: try: db = __buscarLlaveBaseDato(database) codificacion = "" if db is not None: if encoding == "ASCII": codificacion = "ascii" elif encoding == "ISO-8859-1": codificacion = "iso-8859-1" elif encoding == "UTF8": codificacion = "utf8" if codificacion != "": db[1] = codificacion generalDict[database] = db ser("data/info/datos.bin", generalDict) return 0 else: return 3 else: return 2 except Exception: return 1