Ejemplo n.º 1
0
Archivo: Bases.py Proyecto: GleyP/Test
def dropTable(database, table):
    if searchInMode(table) != None:
        currentMode = searchInMode(table)
        if currentMode == 'avl':
            # avlList.append(tableNew)
            return avl.dropTable(database, table)
        elif currentMode == 'b':
            # bList.append(tableNew)
            return b.dropTable(database, table)
        elif currentMode == 'bplus':
            # bplusList.append(tableNew)
            return bplus.dropTable(database, table)
        elif currentMode == 'dict':
            # dictList.append(tableNew)
            return DM.dropTable(database, table)
        elif currentMode == 'isam':
            # isamList.append(tableNew)
            return isam.dropTable(database, table)
        elif currentMode == 'json':
            # jsonList.append(tableNew)
            return j.dropTable(database, table)
        elif currentMode == 'hash':
            # hashList.append(tableNew)
            return Hash.dropTable(database, table)
    else:
        return 2
Ejemplo n.º 2
0
def dropTable(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.dropTable(database, table)
            elif modoDB == "b":
                retorno = b.dropTable(database, table)
            elif modoDB == "bplus":
                retorno = bPlus.dropTable(database, table)
            elif modoDB == "dict":
                retorno = dic.dropTable(database, table)
            elif modoDB == "isam":
                retorno = isam.dropTable(database, table)
            elif modoDB == "json":
                retorno = json.dropTable(database, table)
            elif modoDB == "hash":
                retorno = hash.dropTable(database, table)
            return retorno
        else:
            return 2

    except Exception:
        return 1
Ejemplo n.º 3
0
def __drop_table_sp(database, table, mode):
    dbs = databases.find_all(database)
    if dbs == []:
        return 2
    if databases.find_table(database, table) == None:
        return 3
    for db in dbs:
        if db.mode == mode == "avl":
            result = avlMode.dropTable(database, table)
        elif db.mode == mode == "b":
            result = BMode.dropTable(database, table)
        elif db.mode == mode == "bplus":
            result = BPlusMode.dropTable(database, table)
        elif db.mode == mode == "dict":
            result = DictMode.dropTable(database, table)
        elif db.mode == mode == "isam":
            result = ISAMMode.dropTable(database, table)
        elif db.mode == mode == "json":
            result = jsonMode.dropTable(database, table)
        elif db.mode == mode == "hash":
            result = HashMode.dropTable(database, table)
        else:
            continue
        if result != 3:
            if result == 0:
                db.tables.delete(table)
                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 dropTable(database: str, table: str) -> int:
    """Deletes a table in a database (including all of its content)

        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
    """

    bd = _database(database)

    if bd:

        tb = _table(database, table)

        if tb:

            mode = tb["modo"]

            val = -1

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

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

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

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

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

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

            elif mode == "dict":
                val = dict.dropTable(database, table)
                
            if val == 0:
                _database(database)["tablas"].remove(_table(database, table))
                _Guardar()

            return val

        else:
            return 3

    else:
        return 2
Ejemplo n.º 5
0
def dropTable(database: str, table: str) -> int:
    """Deletes a table in a database (including all of its content)

        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
    """

    bd = _Buscar(database)

    if bd:

        mode = bd[1]

        val = -1

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

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

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

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

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

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

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

        return val

    else:
        return 2
Ejemplo n.º 6
0
def dropTable(database, name_table):
    ModeDB, indexDB = exist_Alter(database)
    if ModeDB:
        mode = ModeDB.get_mode()
        if mode.lower().strip() == "avl":
            return avl.dropTable(database, name_table)
        elif mode.lower().strip() == "b":
            return b.dropTable(database, name_table)
        elif mode.lower().strip() == "bPlus".lower():
            return bPlus.dropTable(database, name_table)
        elif mode.lower().strip() == "dict":
            return diccionario.dropTable(database, name_table)
        elif mode.lower().strip() == "hash":
            return hash.dropTable(database, name_table)
        elif mode.lower().strip() == "isam":
            return isam.dropTable(database, name_table)
        elif mode.lower().strip() == "json":
            return json.dropTable(database, name_table)
Ejemplo n.º 7
0
def alterTableMode(database: str, table: str, databaseRef: str, mode: str):
    if exist_Alter(database) and exist_Alter(databaseRef) and exist_Alter(
            databaseRef)[0].get_mode() == mode:
        ModeDB, indice = exist_Alter(database)
        if ModeDB:
            oldMode = ModeDB.get_mode()
            if oldMode.lower().strip() == "avl":
                tables = avl.showTables(database)
                for tabla in tables:
                    if tabla == table:
                        listaDatos = get_Data(
                            database, tabla,
                            oldMode)  # UNA LISTA VACIA NO EJECUTA EL FOR
                        numberColumns = len(listaDatos[0])
                        insertAlter(databaseRef, tabla, numberColumns, mode,
                                    listaDatos)
                avl.dropTable(database, table)
            elif oldMode.lower().strip() == "b":
                tables = b.showTables(database)
                for tabla in tables:
                    if tabla == table:
                        listaDatos = get_Data(database, tabla, oldMode)
                        numberColumns = len(listaDatos[0])
                        insertAlter(databaseRef, tabla, numberColumns, mode,
                                    listaDatos)
                b.dropTable(database, table)
            elif oldMode.lower().strip() == "bPlus".lower():
                tables = bPlus.showTables(database)
                for tabla in tables:
                    if tabla == table:
                        listaDatos = get_Data(database, tabla, oldMode)
                        numberColumns = len(listaDatos[0])
                        insertAlter(databaseRef, tabla, numberColumns, mode,
                                    listaDatos)
                bPlus.dropTable(database, table)
            elif oldMode.lower().strip() == "dict":
                tables = diccionario.showTables(database)
                for tabla in tables:
                    if tabla == table:
                        listaDatos = get_Data(database, tabla, oldMode)
                        numberColumns = len(listaDatos[0])
                        insertAlter(databaseRef, tabla, numberColumns, mode,
                                    listaDatos)
                diccionario.dropTable(database, table)
            elif oldMode.lower().strip() == "isam":
                tables = isam.showTables(database)
                for tabla in tables:
                    if tabla == table:
                        listaDatos = get_Data(database, tabla, oldMode)
                        numberColumns = len(listaDatos[0])
                        insertAlter(databaseRef, tabla, numberColumns, mode,
                                    listaDatos)
                isam.dropTable(database, table)
            elif oldMode.lower().strip() == "hash":
                tables = hash.showTables(database)
                for tabla in tables:
                    if tabla == table:
                        listaDatos = get_Data(database, tabla, oldMode)
                        numberColumns = len(listaDatos[0])
                        insertAlter(databaseRef, tabla, numberColumns, mode,
                                    listaDatos)
                hash.dropTable(database, table)
            elif oldMode.lower().strip() == "json":
                tables = json.showTables(database)
                for tabla in tables:
                    if tabla == table:
                        listaDatos = get_Data(database, tabla, oldMode)
                        numberColumns = len(listaDatos[0])
                        insertAlter(databaseRef, tabla, numberColumns, mode,
                                    listaDatos)
                json.dropTable(database, table)
    else:
        return None