Пример #1
0
def insertAlter(database, tabla, numberColumns, mode, listaDatos):
    if mode.lower().strip() == "avl":
        avl.createTable(database, tabla, numberColumns)
        for data in listaDatos:
            avl.insert(database, tabla, data)
    elif mode.lower().strip() == "b":
        b.createTable(database, tabla, numberColumns)
        for data in listaDatos:
            b.insert(database, tabla, data)
    elif mode.lower().strip() == "bPlus".lower():
        bPlus.createTable(database, tabla, numberColumns)
        for data in listaDatos:
            bPlus.insert(database, tabla, data)
    elif mode.lower().strip() == "dict":
        diccionario.createTable(database, tabla, numberColumns)
        for data in listaDatos:
            diccionario.insert(database, tabla, data)
    elif mode.lower().strip() == "isam":
        isam.createTable(database, tabla, numberColumns)
        for data in listaDatos:
            isam.insert(database, tabla, data)
    elif mode.lower().strip() == "hash":
        hash.createTable(database, tabla, numberColumns)
        for data in listaDatos:
            hash.insert(database, tabla, data)
    elif mode.lower().strip() == "json":
        json.createTable(database, tabla, numberColumns)
        for data in listaDatos:
            json.insert(database, tabla, data)
Пример #2
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)
Пример #3
0
def __createDatabase(database: str, mode: str, encoding: str) -> int:
    try:
        retorno = 3
        if encoding in ["ascii", "iso-8859-1", "utf8"]:
            if __buscarLlaveBaseDato(database) is not None: 
                if mode ==  "avl":
                    retorno = avl.createDatabase(database)
                elif mode ==  "b":
                    retorno = b.createDatabase(database)
                elif mode ==  "bplus":
                    retorno = bPlus.createDatabase(database)
                elif mode ==  "dict":
                    retorno = dic.createDatabase(database)
                elif mode ==  "isam":
                    retorno = isam.createDatabase(database)
                elif mode ==  "json":
                    retorno = json.createDatabase(database)
                elif mode ==  "hash":
                    retorno = hash.createDatabase(database)
                else:
                    retorno = 3
                
                return retorno
            else:
                return 2
        else:
            return 4
    except Exception:
        return 1
Пример #4
0
def alterAddPK(database, table, columns):
    dbs = databases.find_all(database)
    if dbs == []:
        return 2
    for db in dbs:
        if db.mode == "avl":
            result = avlMode.alterAddPK(database, table, columns)
        elif db.mode == "b":
            result = BMode.alterAddPK(database, table, columns)
        elif db.mode == "bplus":
            result = BPlusMode.alterAddPK(database, table, columns)
        elif db.mode == "dict":
            result = DictMode.alterAddPK(database, table, columns)
        elif db.mode == "isam":
            result = ISAMMode.alterAddPK(database, table, columns)
        elif db.mode == "json":
            result = jsonMode.alterAddPK(database, table, columns)
        elif db.mode == "hash":
            result = HashMode.alterAddPK(database, table, columns)
        if result != 3:
            if result == 0:
                db.tables.search(table).pk += columns
                for x in range(5):
                    try:
                        Serializable.commit(databases, "lista_bases_de_datos")
                        return result
                    except:
                        break
                return 1
            break
    return result
Пример #5
0
def createDatabase(database: str, mode: str, encoding: str) -> int:
    try:
        retorno = 3
        if encoding in ["ascii", "iso-8859-1", "utf8"]:
            if __buscarLlaveBaseDato(database) is None: 
                if mode ==  "avl":
                    retorno = avl.createDatabase(database)
                elif mode ==  "b":
                    retorno = b.createDatabase(database)
                elif mode ==  "bplus":
                    retorno = bPlus.createDatabase(database)
                elif mode ==  "dict":
                    retorno = dic.createDatabase(database)
                elif mode ==  "isam":
                    retorno = isam.createDatabase(database)
                elif mode ==  "json":
                    retorno = json.createDatabase(database)
                elif mode ==  "hash":
                    retorno = hash.createDatabase(database)
                else:
                    retorno = 3
                if retorno == 0:
                    generalDict.setdefault(database, [mode, encoding, {}, {}])
                    ser("data/info/datos.bin", generalDict)
                return retorno
            else:
                return 2
        else:
            return 4
    except Exception:
        return 1
Пример #6
0
def createdatabase(db, modo, cod):
    if not modo in modos:
        return 3
    if not cod in encoding:
        return 4
    if buscar(db) == None:
        if modo == "avl":
            tmp = avl.createDatabase(db)

        elif modo == "b":
            tmp = b.createDatabase(db)

        elif modo == "bplus":
            tmp = bplus.createDatabase(db)

        elif modo == "hash":
            tmp = hash.createDatabase(db)

        elif modo == "isam":
            tmp = isam.createDatabase(db)

        elif modo == "json":
            tmp = json.createDatabase(db)

        elif modo == "dict":
            tmp = dict.createDatabase(db)
    else:
        return 2

    if tmp == 0:
        lista_db.append([db, modo, cod])
        return 0
    else:
        return 1
Пример #7
0
def extractRow(database: str, table: str, columns: list) -> list:
    try:
        retorno = 1
        db = __buscarLlaveBaseDato(database)
        if db is not None:
            modoDB = db[0]
            if modoDB == "avl":
                retorno = avl.extractRow(database, table, columns)
            elif modoDB == "b":
                retorno = b.extractRow(database, table, columns)
            elif modoDB == "bplus":
                retorno = bPlus.extractRow(database, table, columns)
            elif modoDB == "dict":
                retorno = dic.extractRow(database, table, columns)
            elif modoDB == "isam":
                retorno = isam.extractRow(database, table, columns)
            elif modoDB == "json":
                retorno = json.extractRow(database, table, columns)
            elif modoDB == "hash":
                retorno = hash.extractRow(database, table, columns)
            return retorno
        else:
            return []

    except Exception:
        return []
Пример #8
0
def createTable(database: str, table: str, numberColumns: int) -> int:
    try:
        retorno = 1
        db = __buscarLlaveBaseDato(database)
        if db is not None:
            modoDB = db[0]
            if modoDB == "avl":
                retorno = avl.createTable(database, table, numberColumns)
            elif modoDB == "b":
                retorno = b.createTable(database, table, numberColumns)
            elif modoDB == "bplus":
                retorno = bPlus.createTable(database, table, numberColumns)
            elif modoDB == "dict":
                retorno = dic.createTable(database, table, numberColumns)
            elif modoDB == "isam":
                retorno = isam.createTable(database, table, numberColumns)
            elif modoDB == "json":
                retorno = json.createTable(database, table, numberColumns)
            elif modoDB == "hash":
                retorno = hash.createTable(database, table, numberColumns)
            return retorno
        else:
            return 2

    except Exception:
        return 1
Пример #9
0
def extractTable(database: str, table: str) -> list:
    try:
        retorno = []
        db = __buscarLlaveBaseDato(database)
        modoDB = db[0]
        if db is not None:
            tablas = db[2]
            if tablas:
                if tablas.get(table) is not None:
                    modoDB = tablas[table]

            if modoDB == "avl":
                retorno = avl.extractTable(database, table)
            elif modoDB == "b":
                retorno = b.extractTable(database, table)
            elif modoDB == "bplus":
                retorno = bPlus.extractTable(database, table)
            elif modoDB == "dict":
                retorno = dic.extractTable(database, table)
            elif modoDB == "isam":
                retorno = isam.extractTable(database, table)
            elif modoDB == "json":
                retorno = json.extractTable(database, table)
            elif modoDB == "hash":
                retorno = hash.extractTable(database, table)
            return retorno
        else:
            return None

    except Exception:
        return None
Пример #10
0
def extractRow(database, table, columns):
    if searchInMode(database) != None:
        currentMode = searchInMode(database)
        if currentMode == 'avl':
            # avlList.append(tableNew)
            return avl.extractRow(database, table, columns)
        elif currentMode == 'b':
            # bList.append(tableNew)
            return b.extractRow(database, table, columns)
        elif currentMode == 'bplus':
            # bplusList.append(tableNew)
            return bplus.extractRow(database, table, columns)
        elif currentMode == 'dict':
            # dictList.append(tableNew)
            return DM.extractRow(database, table, columns)
        elif currentMode == 'isam':
            # isamList.append(tableNew)
            return isam.extractRow(database, table, columns)
        elif currentMode == 'json':
            # jsonList.append(tableNew)
            return j.extractRow(database, table, columns)
        elif currentMode == 'hash':
            # hashList.append(tableNew)
            return Hash.extractRow(database, table, columns)
    else:
        return 2
Пример #11
0
def loadCSV(file, database, table):
    if searchInMode(database) != None:
        currentMode = searchInMode(database)
        if currentMode == 'avl':
            # avlList.append(tableNew)
            return avl.loadCSV(file, database, table)
        elif currentMode == 'b':
            # bList.append(tableNew)
            return b.loadCSV(file, database, table)
        elif currentMode == 'bplus':
            # bplusList.append(tableNew)
            return bplus.loadCSV(file, database, table)
        elif currentMode == 'dict':
            # dictList.append(tableNew)
            return DM.loadCSV(file, database, table)
        elif currentMode == 'isam':
            # isamList.append(tableNew)
            return isam.loadCSV(file, database, table)
        elif currentMode == 'json':
            # jsonList.append(tableNew)
            return j.loadCSV(file, database, table)
        elif currentMode == 'hash':
            # hashList.append(tableNew)
            return Hash.loadCSV(file, database, table)
    else:
        return 2
Пример #12
0
def insert(database, table, register):
    if searchInMode(database) != None:
        currentMode = searchInMode(database)
        if currentMode == 'avl':
            # avlList.append(tableNew)
            return avl.insert(database, table, register)
        elif currentMode == 'b':
            # bList.append(tableNew)
            return b.insert(database, table, register)
        elif currentMode == 'bplus':
            # bplusList.append(tableNew)
            return bplus.insert(database, table, register)
        elif currentMode == 'dict':
            # dictList.append(tableNew)
            return DM.insert(database, table, register)
        elif currentMode == 'isam':
            # isamList.append(tableNew)
            return isam.insert(database, table, register)
        elif currentMode == 'json':
            # jsonList.append(tableNew)
            return j.insert(database, table, register)
        elif currentMode == 'hash':
            # hashList.append(tableNew)
            return Hash.insert(database, table, register)
    else:
        return 2
Пример #13
0
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
Пример #14
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
Пример #15
0
def alterTable(database, tableOld, tableNew):
    if searchInMode(tableOld) != None:
        currentMode = searchInMode(tableOld)
        if currentMode == 'avl':
            avlList.append(tableNew)
            return avl.alterTable(database, tableOld, tableNew)
        elif currentMode == 'b':
            bList.append(tableNew)
            return b.alterTable(database, tableOld, tableNew)
        elif currentMode == 'bplus':
            bplusList.append(tableNew)
            return bplus.alterTable(database, tableOld, tableNew)
        elif currentMode == 'dict':
            dictList.append(tableNew)
            return DM.alterTable(database, tableOld, tableNew)
        elif currentMode == 'isam':
            isamList.append(tableNew)
            return isam.alterTable(database, tableOld, tableNew)
        elif currentMode == 'json':
            jsonList.append(tableNew)
            return j.alterTable(database, tableOld, tableNew)
        elif currentMode == 'hash':
            hashList.append(tableNew)
            return Hash.alterTable(database, tableOld, tableNew)
    else:
        return 2
Пример #16
0
def extractTable(database, table):
    if searchInMode(database) != None:
        currentMode = searchInMode(database)
        if currentMode == 'avl':
            # avlList.append(tableNew)
            return avl.extractTable(database, table)
        elif currentMode == 'b':
            # bList.append(tableNew)
            #registros = b.extractTable(database, table) -> [reg,reg2,regi]

            return b.extractTable(database, table)
        elif currentMode == 'bplus':
            # bplusList.append(tableNew)
            return bplus.extractTable(database, table)
        elif currentMode == 'dict':
            # dictList.append(tableNew)
            return DM.extractTable(database, table)
        elif currentMode == 'isam':
            # isamList.append(tableNew)
            return isam.extractTable(database, table)
        elif currentMode == 'json':
            # jsonList.append(tableNew)
            return j.extractTable(database, table)
        elif currentMode == 'hash':
            # hashList.append(tableNew)
            return Hash.extractTable(database, table)
    else:
        return 2
Пример #17
0
def alterDatabase(databaseOld, databaseNew) -> int:
    try:
        retorno = 2
        if __buscarLlaveBaseDato(databaseNew) is None:
            db = __buscarLlaveBaseDato(databaseOld)
            if db is not None:
                modoDB = db[0] 
                if modoDB == "avl":
                    retorno = avl.alterDatabase(databaseOld, databaseNew)
                elif modoDB == "b":
                    retorno = b.alterDatabase(databaseOld, databaseNew)
                elif modoDB == "bplus":
                    retorno = bPlus.alterDatabase(databaseOld, databaseNew)
                elif modoDB == "dict":
                    retorno = dic.alterDatabase(databaseOld, databaseNew)
                elif modoDB == "isam":
                    retorno = isam.alterDatabase(databaseOld, databaseNew)
                elif modoDB == "json":
                    retorno = json.alterDatabase(databaseOld, databaseNew)
                elif modoDB == "hash":
                    retorno = hash.alterDatabase(databaseOld, databaseNew)
                
            if retorno == 0:
                generalDict[databaseNew] = generalDict[databaseOld]
                del generalDict[databaseOld]
                ser("data/info/datos.bin", generalDict)
            return retorno    

        else:
            return 3
    except Exception:
        return 1
Пример #18
0
def createTable(database, table, numbercolumns):
    if searchInMode(database) != None:
        currentMode = searchInMode(database)
        if currentMode == 'avl':
            avlList.append(table)
            return avl.createTable(database, table, numbercolumns)
        elif currentMode == 'b':
            bList.append(table)
            return b.createTable(database, table, numbercolumns)
        elif currentMode == 'bplus':
            bplusList.append(table)
            return bplus.createTable(database, table, numbercolumns)
        elif currentMode == 'dict':
            dictList.append(table)
            return DM.createTable(database, table, numbercolumns)
        elif currentMode == 'isam':
            isamList.append(table)
            return isam.createTable(database, table, numbercolumns)
        elif currentMode == 'json':
            jsonList.append(table)
            return j.createTable(database, table, numbercolumns)
        elif currentMode == 'hash':
            hashList.append(table)
            return Hash.createTable(database, table, numbercolumns)
    else:
        return 2
Пример #19
0
def dropDatabase(database: str) -> int: 
    try:
        retorno = 1
        bd = __buscarLlaveBaseDato(database)
        if bd is not None:
            modoDB = bd[0]
            if modoDB == "avl":
                retorno = avl.dropDatabase(database)
            elif modoDB == "b":
                retorno = b.dropDatabase(database)
            elif modoDB == "bplus":
                retorno = bPlus.dropDatabase(database)
            elif modoDB == "dict":
                retorno = dic.dropDatabase(database)
            elif modoDB == "isam":
                retorno = isam.dropDatabase(database)
            elif modoDB == "json":
                retorno = json.dropDatabase(database)
            elif modoDB == "hash":
                retorno = hash.dropDatabase(database)
            
            if retorno == 0:
                del generalDict[database]
                ser("data/info/datos.bin", generalDict)
            return retorno
        else:
            return 2   
    except Exception:
        return 1
Пример #20
0
def alterTable(database: str, tableOld: str, tableNew: str) -> int:
    try:
        retorno = 1
        db = __buscarLlaveBaseDato(database)
        if db is not None:
            modoDB = db[0]
            tablas = db[2]
            if tablas:
                if tablas.get(tableOld) is not None:
                    modoDB = tablas[tableOld]
            if modoDB == "avl":
                retorno = avl.alterTable(database, tableOld, tableNew)
            elif modoDB == "b":
                retorno = b.alterTable(database, tableOld, tableNew)
            elif modoDB == "bplus":
                retorno = bPlus.alterTable(database, tableOld, tableNew)
            elif modoDB == "dict":
                retorno = dic.alterTable(database, tableOld, tableNew)
            elif modoDB == "isam":
                retorno = isam.alterTable(database, tableOld, tableNew)
            elif modoDB == "json":
                retorno = json.alterTable(database, tableOld, tableNew)
            elif modoDB == "hash":
                retorno = hash.alterTable(database, tableOld, tableNew)
            return retorno
        else:
            return 2

    except Exception:
        return 1
Пример #21
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
Пример #22
0
def insert(database: str, table: str, register: list) -> int:
    try:
        retorno = 1
        codificacionOk = True
        db = __buscarLlaveBaseDato(database)
        if db is not None:
            modoDB = db[0]
            codificacionOk = code.verificaCodificacion(register, database)
            if codificacionOk is True:
                if modoDB == "avl":
                    retorno = avl.insert(database, table, register)
                elif modoDB == "b":
                    retorno = b.insert(database, table, register)
                elif modoDB == "bplus":
                    retorno = bPlus.insert(database, table, register)
                elif modoDB == "dict":
                    retorno = dic.insert(database, table, register)
                elif modoDB == "isam":
                    retorno = isam.insert(database, table, register)
                elif modoDB == "json":
                    retorno = json.insert(database, table, register)
                elif modoDB == "hash":
                    retorno = hash.insert(database, table, register)
                return retorno
            else:
                return 1
        else:
            return 2

    except Exception:
        return 1
Пример #23
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
Пример #24
0
def alterAddFK(database: str, table: str, references: dict) -> int:
    bd = _Buscar(database)

    if bd:

        mode = bd[1]

        val = -1

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

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

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

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

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

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

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

        return val

    else:
        return 2
Пример #25
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
Пример #26
0
def createDatabase(database: str, mode: str, encoding: str):
    if verify_string(database):
        if exist(database): return 2
        if encoding.lower().strip() is "ascii" or encoding.lower().strip() is "iso-8859-1" \
                or encoding.lower().strip() is "utf8":
            status = -1
            if mode.lower().strip() is "avl":
                status = avl.createDatabase(database)
            elif mode.lower().strip() is "b":
                status = b.createDatabase(database)
            elif mode.lower().strip() is "bplus":
                status = bPlus.createDatabase(database)
            elif mode.lower().strip() is "dict":
                status = diccionario.createDatabase(database)
            elif mode.lower().strip() is "isam":
                status = isam.createDatabase(database)
            elif mode.lower().strip() is "json":
                status = json.createDatabase(database)
            elif mode.lower().strip() is "hash":
                status = hash.createDatabase(database)
            else:
                return 3
            if status == 0:
                save_mode(database, mode, encoding)
            return status
        else:
            return 4
    else:
        return 1
Пример #27
0
def loadCSV(file: str, database: str, table: str) -> list:
    try:
        retorno = 1
        db = __buscarLlaveBaseDato(database)
        if db is not None:
            modoDB = db[0]
            if modoDB == "avl":
                retorno = avl.loadCSV(file, database, table)
            elif modoDB == "b":
                retorno = b.loadCSV(file, database, table)
            elif modoDB == "bplus":
                retorno = bPlus.loadCSV(file, database, table)
            elif modoDB == "dict":
                retorno = dic.loadCSV(file, database, table)
            elif modoDB == "isam":
                retorno = isam.loadCSV(file, database, table)
            elif modoDB == "json":
                retorno = json.loadCSV(file, database, table)
            elif modoDB == "hash":
                retorno = hash.loadCSV(file, database, table)
            return retorno
        else:
            return None

    except Exception:
        return None
Пример #28
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
Пример #29
0
def update(database: str, table: str, register: dict, columns: list) -> int:
    try:
        retorno = 1
        db = __buscarLlaveBaseDato(database)
        if db is not None:
            modoDB = db[0]
            if modoDB == "avl":
                retorno = avl.update(database, table, register, columns)
            elif modoDB == "b":
                retorno = b.update(database, table, register, columns)
            elif modoDB == "bplus":
                retorno = bPlus.update(database, table, register, columns)
            elif modoDB == "dict":
                retorno = dic.update(database, table, register, columns)
            elif modoDB == "isam":
                retorno = isam.update(database, table, register, columns)
            elif modoDB == "json":
                retorno = json.update(database, table, register, columns)
            elif modoDB == "hash":
                retorno = hash.update(database, table, register, columns)
            return retorno
        else:
            return 2

    except Exception:
        return 1
Пример #30
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