コード例 #1
0
ファイル: storageManager.py プロジェクト: gonzcaal/tytus
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
コード例 #2
0
def alterDatabase(databaseOld: str, databaseNew: str) -> int:
    """Renames a database

        Parameters:\n
            databaseOld (str): name of the target database
            databaseNew (str): new name of the target database

        Returns:\n
            0: successful operation
            1: an error ocurred
            2: non-existent target database
            3: new database name occupied
    """

    bd = _Buscar(databaseOld)

    if bd:

        if not _Buscar(databaseNew):

            mode = bd[1]

            val = -1

            if mode == "avl":
                val = avl.alterDatabase(databaseOld, databaseNew)

            elif mode == "b":
                val = b.alterDatabase(databaseOld, databaseNew)

            elif mode == "bplus":
                val = bplus.alterDatabase(databaseOld, databaseNew)

            elif mode == "hash":
                val = hash.alterDatabase(databaseOld, databaseNew)

            elif mode == "isam":
                val = isam.alterDatabase(databaseOld, databaseNew)

            elif mode == "json":
                val = json.alterDatabase(databaseOld, databaseNew)

            elif mode == "dict":
                val = dict.alterDatabase(databaseOld, databaseNew)

            if val == 0:
                posicion = lista_general.index(bd)
                bd[0] = databaseNew
                lista_general[posicion] = bd
                serealizar.commit(lista_general, "cache", _main_path)

            return val

        else:
            return 3

    else:
        return 2
コード例 #3
0
def alterDatabase(databaseOld: str, databaseNew: str) -> int:
    """Renames a database

        Parameters:\n
            databaseOld (str): name of the target database
            databaseNew (str): new name of the target database

        Returns:\n
            0: successful operation
            1: an error ocurred
            2: non-existent target database
            3: new database name occupied
    """

    bd = _database(databaseOld)

    if bd:

        if not _database(databaseNew):

            mode = bd["modo"]

            val = -1

            if mode == "avl":
                val = avl.alterDatabase(databaseOld, databaseNew)

            elif mode == "b":
                val = b.alterDatabase(databaseOld, databaseNew)

            elif mode == "bplus":
                val = bplus.alterDatabase(databaseOld, databaseNew)

            elif mode == "hash":
                val = hash.alterDatabase(databaseOld, databaseNew)

            elif mode == "isam":
                val = isam.alterDatabase(databaseOld, databaseNew)

            elif mode == "json":
                val = json.alterDatabase(databaseOld, databaseNew)

            elif mode == "dict":
                val = dict.alterDatabase(databaseOld, databaseNew)

            if val == 0:
                _database(databaseOld)["nombre"]=databaseNew
                _Guardar()

            return val

        else:
            return 3

    else:
        return 2
コード例 #4
0
def alterDatabase(old_db, new_db):
    modeDB, indexDB = exist_Alter(old_db)
    modeDB_new, indexDB_newDB = exist_Alter(new_db)
    if modeDB and modeDB_new is None:
        mode = modeDB.get_mode()
        if mode.lower().strip() == "avl":
            return avl.alterDatabase(old_db, new_db)
        elif mode.lower().strip() == "b":
            return b.alterDatabase(old_db, new_db)
        elif mode.lower().strip() == "bPlus".lower():
            return bPlus.alterDatabase(old_db, new_db)
        elif mode.lower().strip() == "dict":
            return diccionario.alterDatabase(old_db, new_db)
        elif mode.lower().strip() == "hash":
            return hash.alterDatabase(old_db, new_db)
        elif mode.lower().strip() == "isam":
            return isam.alterDatabase(old_db, new_db)
        elif mode.lower().strip() == "json":
            return json.alterDatabase(old_db, new_db)
コード例 #5
0
ファイル: Bases.py プロジェクト: GleyP/Test
def alterDatabase(old, new):
    if searchInMode(old) != None:
        currentMode = searchInMode(old)
        if currentMode == 'avl':
            avlList.append(new)
            return avl.alterDatabase(old, new)
        elif currentMode == 'b':
            bList.append(new)
            return b.alterDatabase(old, new)
        elif currentMode == 'bplus':
            bplusList.append(new)
            return bplus.alterDatabase(old, new)
        elif currentMode == 'dict':
            dictList.append(new)
            return DM.alterDatabase(old, new)
        elif currentMode == 'isam':
            isamList.append(new)
            return isam.alterDatabase(old, new)
        elif currentMode == 'json':
            jsonList.append(new)
            return j.alterDatabase(old, new)
        elif currentMode == 'hash':
            hashList.append(new)
            return Hash.alterDatabase(old, new)