Пример #1
0
def showTables(database: str) -> list:
    try:
        retorno = []
        db = __buscarLlaveBaseDato(database)
        tablas = db[2]
        if db is not None:
            modoDB = db[0]
            if modoDB == "avl":
                retorno = avl.showTables(database)
            elif modoDB == "b":
                retorno = b.showTables(database)
            elif modoDB == "bplus":
                retorno = bPlus.showTables(database)
            elif modoDB == "dict":
                retorno = dic.showTables(database)
            elif modoDB == "isam":
                retorno = isam.showTables(database)
            elif modoDB == "json":
                retorno = json.showTables(database)
            elif modoDB == "hash":
                retorno = hash.showTables(database)
            
            if tablas:
                for x in tablas:
                    retorno.append(str(x))
            return retorno
        else:
            return None

    except Exception:
        return None
Пример #2
0
def showTables(database):
    if searchInMode(database) != None:
        currentMode = searchInMode(database)
        if currentMode == 'avl':
            # avlList.append(tableNew)
            return avl.showTables(database)
        elif currentMode == 'b':
            # bList.append(tableNew)
            return b.showTables(database)
        elif currentMode == 'bplus':
            # bplusList.append(tableNew)
            return bplus.showTables(database)
        elif currentMode == 'dict':
            # dictList.append(tableNew)
            return DM.showTables(database)
        elif currentMode == 'isam':
            # isamList.append(database)
            return isam.showTables(database)
        elif currentMode == 'json':
            # jsonList.append(database)
            return j.showTables(database)
        elif currentMode == 'hash':
            # hashList.append(database)
            return Hash.showTables(database)
    else:
        return 2
Пример #3
0
def checksumDatabase(database, mode: str):
    objet_mode, index = get_object_mode(database)
    if objet_mode is None: return None
    mode_db = objet_mode.get_mode()
    # sha256 -> 1
    if mode.lower().strip() == "sha256":
        data = ""
        if mode_db.lower().strip() == "avl":
            data = avl.showTables(database)
        elif mode_db.lower().strip() == "b":
            data = list()
            for tables in b.showTables(database):
                data.append(b.extractTable(database, tables))
        elif mode_db.lower().strip() == "bPlus".lower():
            data = bPlus.showTables(database)
        elif mode_db.lower().strip() == "dict":
            data = diccionario.showTables(database)
        elif mode_db.lower().strip() == "hash":
            data = hash.showTables(database)
        elif mode_db.lower().strip() == "isam":
            data = isam.showTables(database)
        elif mode_db.lower().strip() == "json":
            data = json.showTables(database)
        return checksum_database(1, database, mode_db, data)
    # md5 -> 2
    elif mode.lower().strip() == "md5":
        data = ""
        if mode_db.lower().strip() == "avl":
            data = avl.showTables(database)
        elif mode_db.lower().strip() == "b":
            data = list()
            for tables in b.showTables(database):
                data.append(b.extractTable(database, tables))

        elif mode_db.lower().strip() == "bPlus".lower():
            data = bPlus.showTables(database)
        elif mode_db.lower().strip() == "dict":
            data = diccionario.showTables(database)
        elif mode_db.lower().strip() == "hash":
            data = hash.showTables(database)
        elif mode_db.lower().strip() == "isam":
            data = isam.showTables(database)
        elif mode_db.lower().strip() == "json":
            data = json.showTables(database)
        return checksum_database(2, database, mode_db, data)
    else:
        return None
Пример #4
0
def alterDatabaseMode(database: str, mode: str):
    ModeDB, indexDB = exist_Alter(database)
    mode_list.pop(indexDB)
    createDatabase(database, mode, ModeDB.get_encondig())
    if ModeDB:

        oldMode = ModeDB.get_mode()
        if oldMode.lower().strip() == "avl":
            tables = avl.showTables(database)
            for tabla in tables:
                listaDatos = get_Data(database, tabla, oldMode)
                numberColumns = len(listaDatos[0])
                insertAlter(database, tabla, numberColumns, mode, listaDatos)
            avl.dropDatabase(database)
        elif oldMode.lower().strip() == "b":
            tables = b.showTables(database)
            for tabla in tables:
                listaDatos = get_Data(database, tabla, oldMode)
                numberColumns = len(listaDatos[0])
                insertAlter(database, tabla, numberColumns, mode, listaDatos)
            b.dropDatabase(database)
        elif oldMode.lower().strip() == "bPlus".lower():
            tables = bPlus.showTables(database)
            for tabla in tables:
                listaDatos = get_Data(database, tabla, oldMode)
                numberColumns = len(listaDatos[0])
                insertAlter(database, tabla, numberColumns, mode, listaDatos)
            bPlus.dropDatabase(database)
        elif oldMode.lower().strip() == "dict":
            tables = diccionario.showTables(database)
            for tabla in tables:
                listaDatos = get_Data(database, tabla, oldMode)
                numberColumns = len(listaDatos[0])
                insertAlter(database, tabla, numberColumns, mode, listaDatos)
            diccionario.dropDatabase(database)
        elif oldMode.lower().strip() == "isam":
            tables = isam.showTables(database)
            for tabla in tables:
                listaDatos = get_Data(database, tabla, oldMode)
                numberColumns = len(listaDatos[0])
                insertAlter(database, tabla, numberColumns, mode, listaDatos)
            isam.dropDatabase(database)
        elif oldMode.lower().strip() == "hash":
            tables = hash.showTables(database)
            for tabla in tables:
                listaDatos = get_Data(database, tabla, oldMode)
                numberColumns = len(listaDatos[0])
                insertAlter(database, tabla, numberColumns, mode, listaDatos)
            hash.dropDatabase(database)
        elif oldMode.lower().strip() == "json":
            tables = json.showTables(database)
            for tabla in tables:
                listaDatos = get_Data(database, tabla, oldMode)
                numberColumns = len(listaDatos[0])
                insertAlter(database, tabla, numberColumns, mode, listaDatos)
            json.dropDatabase(database)
Пример #5
0
def obtenerTablas(database, estructura):
    val = []
    if estructura == 0:
        val = avl_mode.showTables(database)
    elif estructura == 1:
        val = b_mode.showTables(database)
    elif estructura == 2:
        val = bplus_mode.showTables(database)
    elif estructura == 3:
        val = dict_mode.showTables(database)
    elif estructura == 4:
        val = isam_mode.showTables(database)
    elif estructura == 5:
        val = json_mode.showTables(database)
    elif estructura == 6:
        val = hash_mode.showTables(database)
    return val
Пример #6
0
def showTables(database: str) -> list:
    """Show stored tables in a database

        Parameters:\n
            database (str): name of the database

        Returns:\n
            list: successful operation
            None: non-existent database
    """

    bd = _Buscar(database)

    if bd:

        mode = bd[1]

        val = -1

        if mode == "avl":
            val = avl.showTables(database)

        elif mode == "b":
            val = b.showTables(database)

        elif mode == "bplus":
            val = bplus.showTables(database)

        elif mode == "hash":
            val = hash.showTables(database)

        elif mode == "isam":
            val = isam.showTables(database)

        elif mode == "json":
            val = json.showTables(database)

        elif mode == "dict":
            val = dict.showTables(database)

        return val

    else:
        return 2
Пример #7
0
def showTables(database: str) -> list:
    dbs = databases.find_all(database)
    if dbs == []:
        return None
    result = []
    for db in dbs:
        if db.mode == "avl":
            result += avlMode.showTables(database)
        elif db.mode == "b":
            result += BMode.showTables(database)
        elif db.mode == "bplus":
            result += BPlusMode.showTables(database)
        elif db.mode == "dict":
            result += DictMode.showTables(database)
        elif db.mode == "isam":
            result += ISAMMode.showTables(database)
        elif db.mode == "json":
            result += jsonMode.showTables(database)
        elif db.mode == "hash":
            result += HashMode.showTables(database)
    return result
Пример #8
0
def checksumTable(database, table: str, mode: str):
    object_mode, index = get_object_mode(database)
    if object_mode:
        mode_db = object_mode.get_mode()
        if mode.lower().strip() == "sha256":
            data = ""
            if mode_db.lower().strip() == "avl":
                if table.strip() in avl.showTables(database):
                    data = table
                else:
                    return None
            elif mode_db.lower().strip() == "b":
                if table.strip() in b.showTables(database):
                    data = b.extractTable(database, table)
                else:
                    return None
            elif mode_db.lower().strip() == "bPlus".lower():
                if table.strip() in bPlus.showTables(database):
                    data = table
                else:
                    return None
            elif mode_db.lower().strip() == "dict":
                if table.strip() in diccionario.showTables(database):
                    data = table
                else:
                    return None
            elif mode_db.lower().strip() == "hash":
                if table.strip() in hash.showTables(database):
                    data = table
                else:
                    return None
            elif mode_db.lower().strip() == "isam":
                if table.strip() in isam.showTables(database):
                    data = table
                else:
                    return None
            elif mode_db.lower().strip() == "json":
                if table.strip() in json.showTables(database):
                    data = table
                else:
                    return None
            return checksum_table(1, database, mode_db, data)
        elif mode.lower().strip() == "md5":
            data = ""
            if mode_db.lower().strip() == "avl":
                if table.strip() in avl.showTables(database):
                    data = table
                else:
                    return None
            elif mode_db.lower().strip() == "b":
                if table.strip() in b.showTables(database):
                    data = b.extractTable(database, table)
                else:
                    return None
            elif mode_db.lower().strip() == "bPlus".lower():
                if table.strip() in bPlus.showTables(database):
                    data = table
                else:
                    return None
            elif mode_db.lower().strip() == "dict":
                if table.strip() in diccionario.showTables(database):
                    data = table
                else:
                    return None
            elif mode_db.lower().strip() == "hash":
                if table.strip() in hash.showTables(database):
                    data = table
                else:
                    return None
            elif mode_db.lower().strip() == "isam":
                if table.strip() in isam.showTables(database):
                    data = table
                else:
                    return None
            elif mode_db.lower().strip() == "json":
                if table.strip() in json.showTables(database):
                    data = table
                else:
                    return None
            return checksum_table(2, database, mode_db, data)
        else:
            return None
    else:
        return None
Пример #9
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