Пример #1
0
 def execute(self, environment):
     result = jsonMode.extractTable(instruction.dbtemp, self.name)
     if result == None:
         instruction.semanticErrors.append(
             [
                 "La tabla "
                 + str(self.name)
                 + " no pertenece a la base de datos "
                 + instruction.dbtemp,
                 self.row,
             ]
         )
         instruction.syntaxPostgreSQL.append(
             "Error: 42P01: la relacion "
             + instruction.dbtemp
             + "."
             + str(self.name)
             + " no existe"
         )
         return "FATAL ERROR TABLE ID"
     # Almacena una lista con con el nombre y tipo de cada columna
     lst = Struct.extractColumns(instruction.dbtemp, self.name)
     columns = [l.name for l in lst]
     newColumns = [self.name + "." + col for col in columns]
     df = pd.DataFrame(result, columns=newColumns)
     environment.addTable(self.name)
     tempTypes = {}
     for i in range(len(newColumns)):
         tempTypes[newColumns[i]] = lst[i].type
     return [df, tempTypes]
Пример #2
0
    def execute(self, environment):
        Index = File.importFile("Index")
        exists = Index.get(self.name)
        result = []
        if not exists:
            if self.exists:
                result.append("El INDEX : " + self.name + " no existe")
            else:
                result.append("Error: El INDEX : " + self.name + " no existe")
            return result

        if not self.id:
            exists = Index.get(self.newName)
            if not exists:
                Index[self.newName] = Index.pop(self.name)
                result.append("Se cambio el nombre del INDEX : " + self.name +
                              " a " + self.newName)
            else:
                result.append("Error: El INDEX : " + self.newName +
                              " ya existe")
        else:
            column = self.newName
            index = Index[self.name]
            for c in index["Columns"]:
                if c["Name"] == column:
                    if type(self.id) == int:
                        table = index["Table"]
                        columns = Struct.extractColumns(
                            instruction.dbtemp, table)
                        if columns:
                            if self.id > len(columns):
                                result.append("Error fatal: INDEX " +
                                              self.name +
                                              "numero de columna invalido")
                            else:
                                col = columns[self.id - 1].name
                                c["Name"] = col
                                result.append("INDEX : " + self.name +
                                              " cambio la columna " + column +
                                              " por " + col)
                        else:
                            result.append("Error fatal: INDEX " + self.name)
                    else:
                        c["Name"] = self.id
                        result.append("INDEX : " + self.name +
                                      " cambio la columna " + column +
                                      " por " + self.id)

                    Index[self.name] = index
                    break
        if result == []:
            result.append("Error fatal: INDEX " + self.name +
                          " columna invalida : " + self.newName)
        File.exportFile(Index, "Index")
        return result
Пример #3
0
 def execute(self, environment):
     result = jsonMode.extractTable(dbtemp, self.name)
     if result == None:
         return "FATAL ERROR TABLE ID"
     # Almacena una lista con con el nombre y tipo de cada columna
     lst = Struct.extractColumns(dbtemp, self.name)
     columns = [l.name for l in lst]
     newColumns = [self.name + "." + col for col in columns]
     df = pd.DataFrame(result, columns=newColumns)
     environment.addTable(self.name)
     return df
Пример #4
0
 def ambiguityBetweenColumns(self, column):
     """
     Encarga de buscar ambiguedad de una columna entre todas las tablas de
     la clausula FROM
     """
     env = self
     i = 0
     table = ""
     for t in env.tables:
         lst = Struct.extractColumns(env.database, t)
         for l in lst:
             if l.name == column:
                 i += 1
                 table = t
     if i > 1:
         print("Error: Existe ambiguedad entre la culumna:", column)
         return
     return table
Пример #5
0
 def execute(self, environment):
     result = jsonMode.extractTable(dbtemp, self.name)
     if result == None:
         sintaxPostgreSQL.insert(
             len(sintaxPostgreSQL),
             "Error: 42P01: la relacion " + dbtemp + "." + str(self.name) +
             " no existe",
         )
         return "FATAL ERROR TABLE ID"
     # Almacena una lista con con el nombre y tipo de cada columna
     lst = Struct.extractColumns(dbtemp, self.name)
     columns = [l.name for l in lst]
     newColumns = [self.name + "." + col for col in columns]
     df = pd.DataFrame(result, columns=newColumns)
     environment.addTable(self.name)
     tempTypes = {}
     for i in range(len(newColumns)):
         tempTypes[newColumns[i]] = lst[i].type
     return [df, tempTypes]