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.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 deleteColumn(self, database: Database, table: Table, column: Column, noLine, noColumn): """ Method to remove a column in table :param database: Table database :param table: The name of table :param column: Number of columns :param noLine: The instruction line :param noColumn: The instruction column :return: Returns nothing """ dbStatement = jsonMode.alterDropColumn(database.name, table.name, column.number) if dbStatement == 0: if column: table.remove(column) self.writeFile() print('Column deleted successfully') return desc = f": Column {column.name} does not exist" ErrorController().addExecutionError(26, 'Execution', desc, noLine, noColumn) elif dbStatement == 1: desc = f": Can't update Table {table.name}" ErrorController().addExecutionError(34, 'Execution', desc, noLine, noColumn) elif dbStatement == 2: desc = f": Database {database.name} does not exist" ErrorController().addExecutionError(35, 'Execution', desc, noLine, noColumn) elif dbStatement == 3: desc = f": Table {table.name} does not exist" ErrorController().addExecutionError(27, 'Execution', desc, noLine, noColumn) elif dbStatement == 4: print('Out of range column')