示例#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 validateUnique(database, table, value, index):
    records = jsonMode.extractTable(database, table)
    if records == []:
        return
    for record in records:
        if value == record[index]:
            lstErr.append("El Valor " + str(value) +
                          " ya existe dentro de la tabla")
            syntaxPostgreErrors("Error: 23505: El valor " + str(value) +
                                " ya existe dentro de la tabla")
            break
示例#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 validatePrimary(database, table, values, index):
    records = jsonMode.extractTable(database, table)
    if records == []:
        return
    for record in records:
        lst1 = []
        lst2 = []
        for j in index:
            lst1.append(record[j])
            lst2.append(values[j].value)
        if lst1 == lst2:
            lstErr.append("Llaves primarias existentes dentro de la tabla")
            syntaxPostgreErrors("Error: 23505: llaves primarias duplicadas ")
            break
示例#5
0
def validateForeign(database, values, value):
    # values = [references,column]
    references = values[0]
    column = values[1]

    records = jsonMode.extractTable(database, references)

    if records == []:
        lstErr.append("El Valor " + str(value) + " no es una llave foranea")
        return

    index = S.getIndex(database, references, column)

    for record in records:
        if value == record[index]:
            return
    lstErr.append("El Valor " + str(value) + " no es una llave primaria")
示例#6
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]