Esempio n. 1
0
def truncate(database: str, table: str) -> int:
    try:
        retorno = 1
        db = __buscarLlaveBaseDato(database)
        if db is not None:
            modoDB = db[0]
            if modoDB == "avl":
                retorno = avl.truncate(database, table)
            elif modoDB == "b":
                retorno = b.truncate(database, table)
            elif modoDB == "bplus":
                retorno = bPlus.truncate(database, table)
            elif modoDB == "dict":
                retorno = dic.truncate(database, table)
            elif modoDB == "isam":
                retorno = isam.truncate(database, table)
            elif modoDB == "json":
                retorno = json.truncate(database, table)
            elif modoDB == "hash":
                retorno = hash.truncate(database, table)
            return retorno
        else:
            return 2

    except Exception:
        return 1
Esempio n. 2
0
File: Bases.py Progetto: GleyP/Test
def truncate(database, table):
    if searchInMode(database) != None:
        currentMode = searchInMode(database)
        if currentMode == 'avl':
            # avlList.append(tableNew)
            return avl.truncate(database, table)
        elif currentMode == 'b':
            # bList.append(tableNew)
            return b.truncate(database, table)
        elif currentMode == 'bplus':
            # bplusList.append(tableNew)
            return bplus.truncate(database, table)
        elif currentMode == 'dict':
            # dictList.append(tableNew)
            return DM.truncate(database, table)
        elif currentMode == 'isam':
            # isamList.append(tableNew)
            return isam.truncate(database, table)
        elif currentMode == 'json':
            # jsonList.append(tableNew)
            return j.truncate(database, table)
        elif currentMode == 'hash':
            # hashList.append(tableNew)
            return Hash.truncate(database, table)
    else:
        return 2
Esempio n. 3
0
def truncate(database, table):
    dbs = databases.find_all(database)
    if dbs == []:
        return 2
    if databases.find_table(database, table) == None:
        return 3
    result = 1
    for db in dbs:
        if db.tables.search(table) == None:
            continue
        if db.mode == "avl":
            result = avlMode.truncate(database, table)
        elif db.mode == "b":
            result = BMode.truncate(database, table)
        elif db.mode == "bplus":
            result = BPlusMode.truncate(database, table)
        elif db.mode == "dict":
            result = DictMode.truncate(database, table)
        elif db.mode == "isam":
            result = ISAMMode.truncate(database, table)
        elif db.mode == "json":
            result = jsonMode.truncate(database, table)
        elif db.mode == "hash":
            result = HashMode.truncate(database, table)
    return result
Esempio n. 4
0
def truncate(database: str, table: str) -> int:
    """Deletes the content 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
    """

    bd = _database(database)

    if bd:

        tb = _table(database, table)

        if tb:

            mode = tb["modo"]

            val = -1

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

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

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

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

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

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

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

            return val

        else:
            return 3

    else:
        return 2
Esempio n. 5
0
def truncate(database, name_table):
    ModeDB, indexDB = exist_Alter(database)
    if ModeDB:
        mode = ModeDB.get_mode()
        if mode.lower().strip() == "avl":
            return avl.truncate(database, name_table)
        elif mode.lower().strip() == "b":
            return b.truncate(database, name_table)
        elif mode.lower().strip() == "bPlus".lower():
            return bPlus.truncate(database, name_table)
        elif mode.lower().strip() == "dict":
            return diccionario.truncate(database, name_table)
        elif mode.lower().strip() == "hash":
            return hash.truncate(database, name_table)
        elif mode.lower().strip() == "isam":
            return isam.truncate(database, name_table)
        elif mode.lower().strip() == "json":
            return json.truncate(database, name_table)
Esempio n. 6
0
def truncate(database, table):
    db = databases.search(database)
    if db == None:
        return 2
    if db.mode == "avl":
        result = avlMode.truncate(database, table)
    elif db.mode == "b":
        result = BMode.truncate(database, table)
    elif db.mode == "bplus":
        result = BPlusMode.truncate(database, table)
    elif db.mode == "dict":
        result = DictMode.truncate(database, table)
    elif db.mode == "isam":
        result = ISAMMode.truncate(database, table)
    elif db.mode == "json":
        result = jsonMode.truncate(database, table)
    elif db.mode == "hash":
        result = HashMode.truncate(database, table)
    return result