def ejecutar_sql(self): global report_error global report_ast DataWindow().clearConsole() SymbolTable().destroy() ThreeAddressCode().destroy() texto = self.entrada.get('1.0', END) result = parse(texto) # jsonStr = json.dumps(result, default=lambda o: o.__dict__) #Convierte el AST a formato JSON para poder saber como se esta formando # print(result) # Imprime el AST report_error = ReportError() if len(ErrorController().getList()) > 0: messagebox.showerror('ERRORES', 'Se encontraron errores') else: result2 = parse2(texto) report_ast = result2 # ---------- TEST --------- for inst in result: # esto es por los select anidados (subquerys), no encontre otra menera # de retornar la tabla dibujada, lo hacia en mi clase # pero si lo dejaba ahi me tronaban las subquery, # prueben que no les de problema if isinstance(inst, Select): result = inst.process(0) if isinstance(result, DataFrame): DataWindow().consoleText(format_df(result)) elif isinstance(result, list): DataWindow().consoleText(format_table_list(result)) else: inst.process(0)
def execution(input): querys = [] messages = [] DataWindow().clearProperties() result = parse(input) errors = ErrorController().getList() if len(ErrorController().getList()) == 0: for inst in result: if isinstance(inst, Select): result = inst.process(0) if isinstance(result, DataFrame): DataWindow().format_df(result) querys.append([DataWindow().headers, DataWindow().rows]) elif isinstance(result, list): DataWindow().format_table_list(result) querys.append([DataWindow().headers, [DataWindow().rows]]) else: inst.process(0) querys.append([DataWindow().headers, DataWindow().rows]) messages.append(DataWindow().data) obj = { "messages": messages, "querys": querys, "lexical": errors } return obj
def generar_optimization(self): global report_error global report_ast global report_optimization DataWindow().clearConsole() OptimizationController().destroy() texto = self.entrada.get('1.0', END) list_instrucciones = parse_optimizacion(texto) # print(result) # Imprime el AST report_error = ReportError() report_optimization = ReportOfOptimization() if len(ErrorController().getList()) > 0: messagebox.showerror('ERRORES', 'Se encontraron errores') else: for index, inst in enumerate(list_instrucciones): if inst != None: result = inst.process(0) regla1(result, list_instrucciones, index) regla2(result, list_instrucciones, index) regla3(result, list_instrucciones, index) regla4y5(result, list_instrucciones, index) regla6(result, list_instrucciones, index) regla7(result, list_instrucciones, index) DataWindow().consoleText('CD3 RETURNED: Optimization Finished')
def generar_tac(self): global report_error global report_ast DataWindow().clearConsole() SymbolTable().destroy() ThreeAddressCode().destroy() texto = self.entrada.get('1.0', END) result = parse(texto) print(result) # Imprime el AST report_error = ReportError() if len(ErrorController().getList()) > 0: messagebox.showerror('ERRORES', 'Se encontraron errores') else: ambito = Ambito(None) for inst in result: inst.compile(ambito) DataWindow().consoleText(ThreeAddressCode().getCode()) ThreeAddressCode().writeFile() result2 = parse2(texto) # AST GRAFICO report_ast = result2
def deleteDatabase(self, name: str, line, column): """ Method to remove a database in type checker :param name: The name of the database :param line: The instruction line :param column: The instruction column :return: Returns nothing """ database = self.searchDatabase(name) if not database: desc = f": Database {name} does not exist" ErrorController().add(35, 'Execution', desc, line, column) return dbStatement = data_mode(database.mode).dropDatabase(name.lower()) if dbStatement == 0: self._typeCheckerList.remove(database) self.writeFile() SymbolTable().delete(database) DataWindow().consoleText( 'Query returned successfully: Database deleted') elif dbStatement == 1: desc = f": Can't drop database {name}" ErrorController().add(34, 'Execution', desc, line, column) elif dbStatement == 2: desc = f": Database {name} does not exist" ErrorController().add(35, 'Execution', desc, line, column)
def createDatabase(self, database: Database, line, column): """ Method to create a database in type checker :param database: Database object :param line: The instruction line :param column: The instruction column :return: Returns nothing """ if self.searchDatabase(database.name): desc = f": Database {database.name} already exists" ErrorController().add(30, 'Execution', desc, line, column) return dbStatement = data_mode(database.mode).createDatabase( database.name.lower()) if dbStatement == 0: self._typeCheckerList.append(database) self.writeFile() SymbolTable().add(database, 'New Database', 'Database', 'Global', None, line, column) DataWindow().consoleText( 'Query returned successfully: Database created') elif dbStatement == 1: desc = f": Can't create database {database.name}" ErrorController().add(34, 'Execution', desc, line, column) elif dbStatement == 2: desc = f": Database {database.name} already exists" ErrorController().add(30, 'Execution', desc, line, column)
def process(self, instrucction): databases = DataController().showDatabases() if self._patherMatch != None: if self._patherMatch.value[0] == '%' and self._patherMatch.value[-1] == '%': # Busca en cualquier parte pattern = rf"{self._patherMatch.value[1:-1].lower()}" databases = list(filter(lambda x: re.findall(pattern, x.lower()), databases)) elif self._patherMatch.value[0] == '%': # Busca al final pattern = rf".{{0,}}{self._patherMatch.value[1:].lower()}$" databases = list(filter(lambda x: re.match(pattern, x.lower()), databases)) elif self._patherMatch.value[-1] == '%': # Busca al inicio pattern = rf"{self._patherMatch.value[:-1].lower()}" databases = list(filter(lambda x: re.findall(pattern, x.lower()), databases)) else: # Busca especificamente pattern = rf"{self._patherMatch.value.lower()}$" databases = list(filter(lambda x: re.match(pattern, x.lower()), databases)) columnsData = [] for db in databases: columnsData.append([db]) DataWindow().consoleTable(['Databases'], columnsData)
def process(self, enviroment): if self.isColumn: isChangeName = self.rename_column( self.name_index, self.new_name, self.index_specific) if isChangeName: DataWindow().consoleText('Query returned successfully: Alter Index') else: desc = f": Name of Index not Exists" ErrorController().add(4, 'Execution', desc, self.line, self.column) # manejar linea y columna else: isChangeName = self.search_index(self.name_index, self.new_name) if isChangeName: DataWindow().consoleText('Query returned successfully: Alter Index') else: desc = f": Name of Index not Exists" ErrorController().add(4, 'Execution', desc, self.line, self.column) # manejar linea y columna
def process(self, enviroment): for name in self.name_index: isDropIndex = self.search_index(name) if isDropIndex: DataWindow().consoleText('Query returned successfully: Drop Index') else: desc = f": Name of Index not Exists" ErrorController().add(4, 'Execution', desc, self.line, self.column) # manejar linea y columna
def add(self, noType, errorType, desc, line, column): numberError, description = get_type_error(noType) self._idError += 1 description += f": {desc}" description = ' '.join(description.split()) description = description.replace(': :', ':') self._errorsList.append( Error(self._idError, errorType, numberError, description, line, column)) DataWindow().consoleTable(['Code', 'Description'], [[numberError, description]])
def process(self, instrucction): typeChecker = TypeChecker() database = typeChecker.searchDatabase(self._dbActual) if not database: desc = f": Database {self._dbActual} does not exist" ErrorController().add(35, 'Execution', desc, self._noLine, self._noColumn) return SymbolTable().useDatabase = database DataWindow().consoleText('Query returned successfully: USE DATABASE')
def alterAddPK(self, name: str, columns: list, noLine, noColumn): """ Method to define primary keys to a database :param name: The name of table :param columns: List with number of columns :param noLine: The instruction line :param noColumn: The instruction column :return: Returns nothing """ database = SymbolTable().useDatabase if not database: desc = f": Database not selected" ErrorController().add(4, 'Execution', desc, noLine, noColumn) return table = TypeChecker().searchTable(database, name) if not table: desc = f": Table {name} does not exist" ErrorController().add(27, 'Execution', desc, noLine, noColumn) return dbStatement = data_mode(database.mode).alterAddPK( database.name.lower(), name.lower(), columns) if dbStatement == 0: for col in table.columns: if col.number in columns: col.primaryKey = True DataWindow().consoleText( 'Query returned successfully: Alter Table add PK') elif dbStatement == 1: ErrorController().add(34, 'Execution', '', noLine, noColumn) elif dbStatement == 2: desc = f": Database {database.name} does not exist" ErrorController().add(35, 'Execution', desc, noLine, noColumn) elif dbStatement == 3: desc = f": Table {name} does not exist" ErrorController().add(27, 'Execution', desc, noLine, noColumn) elif dbStatement == 4: desc = f": Multiple primary keys for table {database.name} are not allowed" ErrorController().add(36, 'Execution', desc, noLine, noColumn) elif dbStatement == 5: desc = f": Column of relation {name} does not exist" ErrorController().add(26, 'Execution', desc, noLine, noColumn)
def deleteColumn(self, table: Table, column: Column, noLine, noColumn): """ Method to remove a column in table :param table: The name of table :param column: Number of columns :param noLine: The instruction line :param noColumn: The instruction column :return: Returns nothing """ database = SymbolTable().useDatabase if not database: desc = f": Database not selected" ErrorController().add(4, 'Execution', desc, noLine, noColumn) return dbStatement = data_mode(database.mode).alterDropColumn( database.name.lower(), table.name.lower(), column.number) if dbStatement == 0: if column: table.remove(column) self.updateColumnIndex(table) self.writeFile() DataWindow().consoleText( 'Query returned successfully: Column deleted') return desc = f": Column {column.name} does not exist" ErrorController().add(26, 'Execution', desc, noLine, noColumn) elif dbStatement == 1: desc = f": Can't update Table {table.name}" ErrorController().add(34, 'Execution', desc, noLine, noColumn) elif dbStatement == 2: desc = f": Database {database.name} does not exist" ErrorController().add(35, 'Execution', desc, noLine, noColumn) elif dbStatement == 3: desc = f": Table {table.name} does not exist" ErrorController().add(27, 'Execution', desc, noLine, noColumn) elif dbStatement == 4: desc = f": Column of relation {column.name} does not exist" ErrorController().add(26, 'Execution', desc, noLine, noColumn)
def createColumnTable(self, table: Table, column: Column, noLine, noColumn): """ Method to create a column in table :param table: The name of table :param column: Number of columns :param noLine: The instruction line :param noColumn: The instruction column :return: Returns nothing """ database = SymbolTable().useDatabase if not database: desc = f": Database not selected" ErrorController().add(4, 'Execution', desc, noLine, noColumn) return if self.searchColumn(table, column.name): desc = f": Column {column.name} already exists" ErrorController().add(29, 'Execution', desc, noLine, noColumn) return dbStatement = data_mode(database.mode).alterAddColumn( database.name.lower(), table.name.lower(), column.default) if dbStatement == 0: if len(table.columns) > 0: column.number = table.columns[-1].number + 1 table.columns.append(column) self.writeFile() DataWindow().consoleText( 'Query returned successfully: Table updated') return True elif dbStatement == 1: desc = f": Can't update table {table.name}" ErrorController().add(34, 'Execution', desc, noLine, noColumn) elif dbStatement == 2: desc = f": Database {database.name} does not exist" ErrorController().add(35, 'Execution', desc, noLine, noColumn) elif dbStatement == 3: desc = f": Table {table.name} does not exist" ErrorController().add(27, 'Execution', desc, noLine, noColumn)
def update(self, name: str, register: dict, columns: list, noLine, noColumn): """ Method to update a record from a table :param name: The name of table :param register: Dictionary where the key is the column number and the value the data :param columns: List with number of columns of primary keys :param noLine: The instruction line :param noColumn: The instruction column :return: Returns nothing """ database = SymbolTable().useDatabase if not database: desc = f": Database not selected" ErrorController().add(4, 'Execution', desc, noLine, noColumn) return None if not TypeChecker().searchTable(database, name): desc = f": Table {name} does not exist" ErrorController().add(27, 'Execution', desc, noLine, noColumn) return None dbStatement = data_mode(database.mode).update(database.name.lower(), name.lower(), register, columns) if dbStatement == 0: DataWindow().consoleText('Query returned successfully: UPDATE') elif dbStatement == 1: ErrorController().add(34, 'Execution', '', noLine, noColumn) elif dbStatement == 2: desc = f": Database {database.name} does not exist" ErrorController().add(35, 'Execution', desc, noLine, noColumn) elif dbStatement == 3: desc = f": Table {name} does not exist" ErrorController().add(27, 'Execution', desc, noLine, noColumn) elif dbStatement == 4: desc = f": Primary key does not exist" ErrorController().add(34, 'Execution', desc, noLine, noColumn)
def dropProcedure(self, name, line, column): self.loadFile() # db = SymbolTable().useDatabase # if not db: # desc = f": Database not selected" # ErrorController().add(4, 'Execution', desc, # line, column) # return # key = f"{name}{db}" key = f"{name}" if key in self.__storedProcedure: DataWindow().consoleText( 'Query returned successfully: Function deleted') self.__storedProcedure.pop(key) self.writeFile() return True return False
def alterDropPK(self, name: str, noLine, noColumn): """ Method to remove primary key :param name: The name of table :param noLine: The instruction line :param noColumn: The instruction column :return: Returns nothing """ database = SymbolTable().useDatabase if not database: desc = f": Database not selected" ErrorController().add(4, 'Execution', desc, noLine, noColumn) return if not TypeChecker().searchTable(database, name): desc = f": Table {name} does not exist" ErrorController().add(27, 'Execution', desc, noLine, noColumn) return dbStatement = data_mode(database.mode).alterDropPK( database.name.lower(), name.lower()) if dbStatement == 0: DataWindow().consoleText( 'Query returned successfully: Alter Table drop PK') elif dbStatement == 1: ErrorController().add(34, 'Execution', '', noLine, noColumn) elif dbStatement == 2: desc = f": Database {database.name} does not exist" ErrorController().add(35, 'Execution', desc, noLine, noColumn) elif dbStatement == 3: desc = f": Table {name} does not exist" ErrorController().add(27, 'Execution', desc, noLine, noColumn) elif dbStatement == 4: desc = f": Column of relation {name} does not exist" ErrorController().add(26, 'Execution', desc, noLine, noColumn)
def updateTable(self, tableOld: str, tableNew: str, line, column): """ Method to update the name of a table in database :param tableOld: The old name of the table :param tableNew: The new name of the table :param line: The instruction line :param column: The instruction column :return: Returns nothing """ database = SymbolTable().useDatabase if not database: desc = f": Database not selected" ErrorController().add(4, 'Execution', desc, line, column) return dbStatement = data_mode(database.mode).alterTable( database.name.lower(), tableOld.lower(), tableNew.lower()) if dbStatement == 0: table = self.searchTable(database, tableOld) table.name = tableNew self.writeFile() DataWindow().consoleText( 'Query returned successfully: Table updated') elif dbStatement == 1: desc = f": Can't update Table {tableOld}" ErrorController().add(34, 'Execution', desc, line, column) elif dbStatement == 2: desc = f": Database {database.name} does not exist" ErrorController().add(35, 'Execution', desc, line, column) elif dbStatement == 3: desc = f": Table {tableOld} does not exist" ErrorController().add(27, 'Execution', desc, line, column) elif dbStatement == 4: desc = f": Table {tableNew} already exists" ErrorController().add(31, 'Execution', desc, line, column)
def insert(self, name: str, data: list, noLine, noColumn): """ Method to insert data to a column :param name: The name of table :param data: Data list :param noLine: The instruction line :param noColumn: The instruction column :return: Returns nothing """ database = SymbolTable().useDatabase if not database: desc = f": Database not selected" ErrorController().add(4, 'Execution', desc, noLine, noColumn) return None dbStatement = data_mode(database.mode).insert(database.name.lower(), name.lower(), data) if dbStatement == 0: DataWindow().consoleText( 'Query returned successfully: INSERT INTO') elif dbStatement == 1: ErrorController().add(34, 'Execution', '', noLine, noColumn) elif dbStatement == 2: desc = f": Database {database.name} does not exist" ErrorController().add(35, 'Execution', desc, noLine, noColumn) elif dbStatement == 3: desc = f": Table {name} does not exist" ErrorController().add(27, 'Execution', desc, noLine, noColumn) elif dbStatement == 4: desc = f": Duplicate key value violates unique" ErrorController().add(24, 'Execution', desc, noLine, noColumn) elif dbStatement == 5: desc = f": Column of relation {name} does not exist" ErrorController().add(26, 'Execution', desc, noLine, noColumn)
def createTable(self, name: str, columns: int, line, column): """ Method to create a table in database :param name: The name of table :param columns: Number of columns :param line: The instruction line :param column: The instruction column :return: Returns nothing """ database = SymbolTable().useDatabase if not database: desc = f": Database not selected" ErrorController().add(4, 'Execution', desc, line, column) return dbStatement = data_mode(database.mode).createTable( database.name.lower(), name.lower(), 0) if dbStatement == 0: table = Table(name) database.tables.append(table) self.writeFile() DataWindow().consoleText( 'Query returned successfully: Table created') return table elif dbStatement == 1: desc = f": Can't create table {name}" ErrorController().add(34, 'Execution', desc, line, column) elif dbStatement == 2: desc = f": Database {database.name} does not exist" ErrorController().add(35, 'Execution', desc, line, column) elif dbStatement == 3: desc = f": Table {name} already exists" ErrorController().add(31, 'Execution', desc, line, column)
def deleteTable(self, name: str, line, column): """ Method to remove a table in database :param database: Table database :param name: The name of table :param line: The instruction line :param column: The instruction column :return: Returns nothing """ database = SymbolTable().useDatabase if not database: desc = f": Database not selected" ErrorController().add(4, 'Execution', desc, line, column) return dbStatement = data_mode(database.mode).dropTable( database.name.lower(), name.lower()) if dbStatement == 0: table = self.searchTable(database, name) database.tables.remove(table) self.writeFile() DataWindow().consoleText( 'Query returned successfully: Table deleted') elif dbStatement == 1: desc = f": Can't drop table {name}" ErrorController().add(34, 'Execution', desc, line, column) elif dbStatement == 2: desc = f": Database {database.name} does not exist" ErrorController().add(35, 'Execution', desc, line, column) elif dbStatement == 3: desc = f": Table {name} does not exist" ErrorController().add(27, 'Execution', desc, line, column)
def updateDatabase(self, databaseOld: str, databaseNew: str, line, column): """ Method to update the name of a database in type checker :param databaseOld: The old name of the database :param databaseNew: The new name of the database :param line: The instruction line :param column: The instruction column :return: Returns nothing """ database = self.searchDatabase(databaseOld) if not database: desc = f": Database {databaseOld} does not exist" ErrorController().add(35, 'Execution', desc, line, column) return dbStatement = data_mode(database.mode).alterDatabase( databaseOld.lower(), databaseNew.lower()) if dbStatement == 0: database.name = databaseNew self.writeFile() DataWindow().consoleText( 'Query returned successfully: Database updated') elif dbStatement == 1: desc = f": Can't update database {databaseOld}" ErrorController().add(34, 'Execution', desc, line, column) elif dbStatement == 2: desc = f": Database {databaseOld} does not exist" ErrorController().add(35, 'Execution', desc, line, column) elif dbStatement == 3: desc = f": Database {databaseNew} already exists" ErrorController().add(30, 'Execution', desc, line, column)
def truncate(self, name: str, noLine, noColumn): """ Method to delete a record from a table :param name: The name of table :param noLine: The instruction line :param noColumn: The instruction column :return: Returns nothing """ database = SymbolTable().useDatabase if not database: desc = f": Database not selected" ErrorController().add(4, 'Execution', desc, noLine, noColumn) return None if not TypeChecker().searchTable(database, name): desc = f": Table {name} does not exist" ErrorController().add(27, 'Execution', desc, noLine, noColumn) return None dbStatement = data_mode(database.mode).truncate( database.name.lower(), name.lower()) if dbStatement == 0: DataWindow().consoleText('Query returned successfully: TRUNCATE') elif dbStatement == 1: ErrorController().add(34, 'Execution', '', noLine, noColumn) elif dbStatement == 2: desc = f": Database {database.name} does not exist" ErrorController().add(35, 'Execution', desc, noLine, noColumn) elif dbStatement == 3: desc = f": Table {name} does not exist" ErrorController().add(27, 'Execution', desc, noLine, noColumn)
def __init__(self, window): self.ventana = window # Defino un titulo para el GUI self.ventana.title('Query Tool') # Defino un fondo para usar, pueden cambiarlo por otro color mas bonito self.ventana.configure(background='#3c3f41') self.ventana.columnconfigure(0, weight=1) self.ventana.rowconfigure(0, weight=1) # Creo un frame para que contenga la intefaz, es como en java se hace con swing frame = LabelFrame(self.ventana) # Posiciono el frame frame.grid(row=0, column=0, columnspan=10, pady=10) # Defino un fondo para usar, pueden cambiarlo por otro color mas bonito frame.configure(background='#3c3f41', borderwidth=0) #############################################_MENU_############################################# # Creo un menu, es decir una lista desplegable barraMenu = Menu(self.ventana) self.ventana.config(menu=barraMenu) archivoMenu = Menu(barraMenu, tearoff=0) #############################################MENU Abrir############################################# archivoOpen = Menu(archivoMenu, tearoff=0) archivoOpen.add_command(label='Abrir Archivo', command=self.open_file_editor) #############################################MENU Archivo############################################# archivoMenu.add_command(label='Nuevo', command=self.nuevo) archivoMenu.add_separator() archivoMenu.add_cascade(label='Abrir', menu=archivoOpen) archivoMenu.add_separator() archivoMenu.add_command(label='Guardar', command=self.guardar) archivoMenu.add_command(label='Guardar como...', command=self.guardar_como) archivoMenu.add_separator() archivoMenu.add_command(label='Ejecutar SQL', command=self.ejecutar_sql) archivoMenu.add_separator() archivoMenu.add_command(label='Generar TAC', command=self.generar_tac) archivoMenu.add_separator() archivoMenu.add_command(label='Generar Optimizacion', command=self.generar_optimization) archivoMenu.add_separator() archivoMenu.add_command(label='Ejecutar TAC', command=ThreeAddressCode().executeFile) archivoMenu.add_separator() archivoMenu.add_command(label='Salir', command=self.terminar) #############################################MENU WINDOWS############################################## windows_menu = Menu(barraMenu, tearoff=0) windows_menu.add_command(label='AST', command=self.report_ast_windows) windows_menu.add_separator() windows_menu.add_command(label='Tabla de errores', command=self.report_errors_windows) windows_menu.add_separator() windows_menu.add_command(label='Tabla de simbolos', command=self.report_symbols_windows) windows_menu.add_separator() windows_menu.add_command(label='Reporte de Optimizacion', command=self.report_optimization_windows) windows_menu.add_separator() windows_menu.add_command(label='Type Checker', command=self.report_typeChecker_windows) windows_menu.add_separator() windows_menu.add_command(label='Reporte Gramatical', command=self.report_bnf_windows) #############################################MENU LINUX################################################ ubuntu_menu = Menu(barraMenu, tearoff=0) ubuntu_menu.add_command(label='AST', command=self.report_ast_ubuntu) ubuntu_menu.add_separator() ubuntu_menu.add_command(label='Tabla de errores', command=self.report_errors_ubuntu) ubuntu_menu.add_separator() ubuntu_menu.add_command(label='Tabla de simbolos', command=self.report_symbols_ubuntu) ubuntu_menu.add_separator() ubuntu_menu.add_command(label='Reporte de Optimizacion', command=self.report_optimization_ubuntu) ubuntu_menu.add_separator() ubuntu_menu.add_command(label='Type Checker', command=self.report_typeChecker_ubuntu) ubuntu_menu.add_separator() ubuntu_menu.add_command(label='Reporte Gramatical', command=self.report_bnf_ubuntu) #############################################MENU REPORTES############################################# archivoReportes = Menu(barraMenu, tearoff=0) archivoReportes.add_cascade(label='Windows', menu=windows_menu) archivoReportes.add_separator() archivoReportes.add_cascade(label='Linux', menu=ubuntu_menu) #############################################MENU PRINCIPAL############################################# barraMenu.add_cascade(label='Archivo', menu=archivoMenu) # anade submenu barraMenu.add_cascade(label='Reportes', menu=archivoReportes) barraMenu.configure(background='SpringGreen') ############################################_ENTRADA_############################################ Label(frame, text='Archivo de Entrada', borderwidth=0, font='Arial 15 bold', width=52, bg='#3c3f41', foreground='#fff').grid(row=3, column=0) hor_scroll = Scrollbar(frame, orient='horizontal') ver_scroll = Scrollbar(frame, orient='vertical') # Crea un scroll por si el texto es muy largo self.entrada = Text(frame, borderwidth=0, height=35, width=70, bg='#2e2e31', foreground='#fff', undo=True, wrap='none', xscrollcommand=hor_scroll.set, yscrollcommand=ver_scroll.set) self.entrada.grid(row=4, column=0, padx=30) ver_scroll.config(command=self.entrada.yview) ver_scroll.grid(column=0, row=4, sticky='NE', ipady=255, padx=12) hor_scroll.config(command=self.entrada.xview) hor_scroll.grid(column=0, row=5, sticky='NS', ipadx=255) # Para este editor aun hay que ver si lo usamos como consola para errores, si no lo quitamos dataWindow = DataWindow() dataWindow.console = frame self.console = dataWindow.console self.console.grid(row=4, column=1, padx=30)
def process(self, instruccion): lista_sort = [] lista_id = [] type_index = self.type_index table = self.table variable = self.variable mode = self.mode lista_valores = self.list_column_reference where_clause = self.where_optional if isinstance(lista_valores, list): for index, data in enumerate(lista_valores): if isinstance(data, bool): if data == True: lista_sort.append('DESC') else: lista_sort.append('ASC') else: lista_id.append(data) if len(lista_id) > len(lista_sort): if index == len(lista_valores) - 1: if len(lista_valores) == 1: lista_sort.append("Not Sort") elif isinstance(data, str): lista_sort.append("Not Sort") else: pass elif isinstance(lista_valores[index+1], bool): pass else: lista_sort.append("Not Sort") isTabla = self.searchTableIndex(table, self.line, self.column) isDuplicate = self.searchDuplicateIndex(self.variable) if isTabla and not isDuplicate: if type_index.lower() == 'index': # Normal if mode == None: SymbolTable().add(Index(type_index, table, variable, 'BTREE', lista_id, lista_sort), variable, 'Index', None, table, self.line, self.column) DataWindow().consoleText('Query returned successfully: Create Index') elif mode.upper() == 'BTREE': SymbolTable().add(Index(type_index, table, variable, 'BTREE', lista_id, lista_sort), variable, 'Index', None, table, self.line, self.column) DataWindow().consoleText('Query returned successfully: Create Index') else: # HASH SymbolTable().add(Index(type_index, table, variable, 'HASH', lista_id, lista_sort), variable, 'Index', None, table, self.line, self.column) DataWindow().consoleText('Query returned successfully: Create Index') else: # Unique if mode == None: SymbolTable().add(Index(type_index, table, variable, 'BTREE', lista_id, lista_sort), variable, 'Index', None, table, self.line, self.column) DataWindow().consoleText('Query returned successfully: Create Index') elif mode.upper() == 'BTREE': SymbolTable().add(Index(type_index, table, variable, 'BTREE', lista_id, lista_sort), variable, 'Index', None, table, self.line, self.column) DataWindow().consoleText('Query returned successfully: Create Index') else: # HASH SymbolTable().add(Index(type_index, table, variable, 'HASH', lista_id, lista_sort), variable, 'Index', None, table, self.line, self.column) DataWindow().consoleText('Query returned successfully: Create Index') else: desc = "FATAL ERROR, la tabla no existe para crear el index o el index es repetido" ErrorController().add(34, 'Execution', desc, self.line, self.column)
def nuevo(self): self.entrada.delete(1.0, END) DataWindow().clearConsole() self.archivo = ''