Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
Archivo: Bases.py Proyecto: GleyP/Test
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
Ejemplo n.º 3
0
def alterDropColumn(database: str, table: str, columnNumber: int) -> int:
    dbs = databases.find_all(database)
    if dbs == []:
        return 2
    for db in dbs:
        if db.mode == "avl":
            result = avlMode.alterDropColumn(database, table, columnNumber)
        elif db.mode == "b":
            result = BMode.alterDropColumn(database, table, columnNumber)
        elif db.mode == "bplus":
            result = BPlusMode.alterDropColumn(database, table, columnNumber)
        elif db.mode == "dict":
            result = DictMode.alterDropColumn(database, table, columnNumber)
        elif db.mode == "isam":
            result = ISAMMode.alterDropColumn(database, table, columnNumber)
        elif db.mode == "json":
            result = jsonMode.alterDropColumn(database, table, columnNumber)
        elif db.mode == "hash":
            result = HashMode.alterDropColumn(database, table, columnNumber)
        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
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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)