Beispiel #1
0
def alterDropPK(database, table):
    if searchInMode(database) != None:
        currentMode = searchInMode(database)
        if currentMode == 'avl':
            # avlList.append(tableNew)
            return avl.alterDropPK(database, table)
        elif currentMode == 'b':
            # bList.append(tableNew)
            return b.alterDropPK(database, table)
        elif currentMode == 'bplus':
            # bplusList.append(tableNew)
            return bplus.alterDropPK(database, table)
        elif currentMode == 'dict':
            # dictList.append(tableNew)
            return DM.alterDropPK(database, table)
        elif currentMode == 'isam':
            # isamList.append(tableNew)
            return isam.alterDropPK(database, table)
        elif currentMode == 'json':
            # jsonList.append(tableNew)
            return j.alterDropPK(database, table)
        elif currentMode == 'hash':
            # hashList.append(tableNew)
            return Hash.alterDropPK(database, table)
    else:
        return 2
Beispiel #2
0
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
Beispiel #3
0
def alterDropPK(database: str, table: str) -> int:
    """Deletes PKs of a table in a database

        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
            4: non-existent PK
    """

    bd = _database(database)

    if bd:

        tb = _table(database, table)

        if tb:

            mode = tb["modo"]

            val = -1

            if mode == "avl":
                val = avl.alterDropPK(database, table)

            elif mode == "b":
                val = b.alterDropPK(database, table)

            elif mode == "bplus":
                val = bplus.alterDropPK(database, table)

            elif mode == "hash":
                val = hash.alterDropPK(database, table)

            elif mode == "isam":
                val = isam.alterDropPK(database, table)

            elif mode == "json":
                val = json.alterDropPK(database, table)

            elif mode == "dict":
                val = dict.alterDropPK(database, table)

            if val == 0:
                _table(database, table)["pk"]=[]
                _Guardar()

            return val

        else:
            return 3

    else:
        return 2