Ejemplo n.º 1
0
    def process(self, instruction):
        typeChecker = TypeChecker()
        nombreTabla = self._table_name.alias
        noCols = self.numberOfColumns(self._column_list)

        resTab = typeChecker.createTable(nombreTabla, noCols, 0,
                                         0)  # TODO add line and column

        # Si devuelve None es porque ya existe la tabla
        if resTab == None:
            return

        # Agrega las propiedades que agrupan a varias columnas
        self.generetaExtraProp()
        # Genera las tablas ya con todas sus propiedades
        self.generateColumns(nombreTabla, typeChecker)

        # Si tiene inherits la manoseamos
        if self._inherits_from != None:
            self.addInherits(nombreTabla, self._inherits_from)

        # Si ocurrio algun error en todo el proceso mato la tabla
        if self._can_create_flag == False:
            typeChecker.deleteTable(nombreTabla, 0, 0)
            return

        # Verifico si tiene llave primaria la tabla o si le meto una escondida
        # if self.existsPK(nombreTabla) == 0:
        #     self.generateHiddenPK(nombreTabla)

        # Agrego llaves primarias a la base de datos si no hubo clavo con la tabla
        self.addPKToDB(nombreTabla)
Ejemplo n.º 2
0
    def agregarNuevoTipo(self, tablaAMod, colAMod, nuevoTipo):
        typeChecker = TypeChecker()
        bandera = False
        tableToAlter = typeChecker.searchTable(SymbolTable().useDatabase,
                                               tablaAMod)

        tipoFinal = {
            '_tipoColumna': str(nuevoTipo._tipoColumna),
            '_paramOne': nuevoTipo._paramOne,
            '_paramTwo': nuevoTipo._paramTwo
        }

        for columna in tableToAlter.columns:
            if (columna._name == colAMod):
                bandera = True
                columna._dataType = tipoFinal
                break

        if not bandera:
            desc = f": Undefined column in alter type ()"
            ErrorController().add(26, 'Execution', desc, 0, 0)
            return
        bandera = False
        typeChecker.writeFile()
        pass
Ejemplo n.º 3
0
    def agregarCheck(self, conditionColumn, tablaId):
        typeChecker = TypeChecker()
        bandera = False
        tableToAlter = typeChecker.searchTable(SymbolTable().useDatabase,
                                               tablaId)

        #                           L (L|D)*
        whatColumnIs = re.search('[a-zA-z]([a-zA-z]|[0-9])*',
                                 conditionColumn.alias)

        if whatColumnIs != None:
            whatColumnIs = whatColumnIs.group(0)
            for columna in tableToAlter.columns:
                if (columna._name == whatColumnIs):
                    bandera = True
                    columna._check = conditionColumn.alias
                    break
            if not bandera:
                desc = f": Undefined column in alter check ()"
                ErrorController().add(26, 'Execution', desc, 0, 0)
                return
            bandera = False

        else:
            desc = f": column not given in check()"
            ErrorController().add(26, 'Execution', desc, 0, 0)
            return
        typeChecker.writeFile()
Ejemplo n.º 4
0
    def process(self, instrucction):
        typeChecker = TypeChecker()
        database = typeChecker.searchDatabase(self._database_name)

        if self._if_exists and not database:
            return

        typeChecker.deleteDatabase(self._database_name, self._noLine,
                                   self._noColumn)
Ejemplo n.º 5
0
    def existsPK(self, tableCreated):
        indicesPrimarios = 0
        typeChecker = TypeChecker()
        tablaToExtract = typeChecker.searchTable(SymbolTable().useDatabase,
                                                 tableCreated)

        for colExt in tablaToExtract._colums:
            if colExt._primaryKey == True:
                indicesPrimarios += 1

        return indicesPrimarios
Ejemplo n.º 6
0
    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')
Ejemplo n.º 7
0
    def addPKToDB(self, tableCreated):
        indicesPrimarios = []
        typeChecker = TypeChecker()
        tablaToExtract = typeChecker.searchTable(SymbolTable().useDatabase,
                                                 tableCreated)

        for colExt in tablaToExtract._colums:
            if colExt._primaryKey == True:
                indicesPrimarios.append(colExt._number)
        if len(indicesPrimarios) == 0:
            pass
        else:
            DataController().alterAddPK(tableCreated, indicesPrimarios, 0, 0)
Ejemplo n.º 8
0
 def generateHiddenPK(self, nombreTabla):
     typeChecker = TypeChecker()
     tipoEscondido = {
         '_tipoColumna': 'HIDDEN',
         '_paramOne': None,
         '_paramTwo': None
     }
     columnaEscondida = Column('HIDDEN', tipoEscondido)
     columnaEscondida._primaryKey = True
     tableToInsert = typeChecker.searchTable(SymbolTable().useDatabase,
                                             nombreTabla)
     typeChecker.createColumnTable(tableToInsert, columnaEscondida, 0, 0)
     print('### SE HA GENERADO UNA LLAVE PRIMARIA ESCONDIDA')
Ejemplo n.º 9
0
    def extractTable(self, name: str, noLine, noColumn) -> list:
        """
        Method to get a list of records from a table

        :param name: The name of table
        :param noLine: The instruction line
        :param noColumn: The instruction column
        :return: Returns a list of records
        """
        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
        # TODO Revisar Esto didier, que con lower me da problema al buscar tablas y base de datos
        data = data_mode(database.mode).extractTable(database.name.lower(),
                                                     name.lower())
        if data == None:
            ErrorController().add(34, 'Execution', '', noLine, noColumn)
            return None

        return data
Ejemplo n.º 10
0
    def extractRow(self, name: str, columns: list, noLine, noColumn) -> list:
        """
        Method to extract a record from a table

        :param name: The name of table
        :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

        data = data_mode(database.mode).extractRow(database.name.lower(),
                                                   name.lower(), columns)
        if data == None:
            ErrorController().add(34, 'Execution', '', noLine, noColumn)
            return None
        return data
Ejemplo n.º 11
0
    def agregarCol(self, columna, nombreTabla):
        typeChecker = TypeChecker()

        tipoFinal = {
            '_tipoColumna': str(columna._type_column._tipoColumna),
            '_paramOne': columna._type_column._paramOne,
            '_paramTwo': columna._type_column._paramTwo
        }

        columnaFinal = Column(columna._column_name, tipoFinal)
        tableToInsert = typeChecker.searchTable(SymbolTable().useDatabase,
                                                nombreTabla)
        validateCol = typeChecker.createColumnTable(tableToInsert,
                                                    columnaFinal, 0, 0)
        # if return None an error ocurrio
        if validateCol == None:
            return
Ejemplo n.º 12
0
    def addForeignKey(self, listaCols, nombreTabla, listaTablasCols):

        # the len of the cols must be de same
        if len(listaCols) != len(listaTablasCols):
            desc = f": cant of params in foreign() != "
            ErrorController().add(36, 'Execution', desc, 0, 0)
            self._can_create_flag = False
            return

        typeChecker = TypeChecker()
        existForeingTable = typeChecker.searchTable(SymbolTable().useDatabase,
                                                    nombreTabla)

        # validate if the foreign table exists
        if existForeingTable == None:
            desc = f": Undefined table in foreign key ()"
            ErrorController().add(27, 'Execution', desc, 0, 0)
            self._can_create_flag = False
            return

        # validate if the columns exists in the foreign table
        for coli in listaTablasCols:
            if typeChecker.searchColumn(existForeingTable, coli) == None:
                desc = f": Undefined col in table in foreign key ()"
                ErrorController().add(26, 'Execution', desc, 0, 0)
                self._can_create_flag = False
                return

        bandera = False
        for x in range(0, len(listaCols)):
            for columna in self._column_list:
                if isinstance(columna, CreateCol):
                    if (columna._column_name == listaCols[x]):
                        if columna._properties != None:
                            bandera = True
                            columna._properties[0]['fk_references_to'] = {
                                '_refTable': nombreTabla,
                                '_refColumn': listaTablasCols[x]
                            }
                            break
            if not bandera:
                desc = f": Undefined column in foreign key ()"
                ErrorController().add(26, 'Execution', desc, 0, 0)
                self._can_create_flag = False
                return
            bandera = False
Ejemplo n.º 13
0
    def agregarNotNull(self, tablaAMod, colAMod):
        typeChecker = TypeChecker()
        bandera = False
        tableToAlter = typeChecker.searchTable(SymbolTable().useDatabase,
                                               tablaAMod)

        for columna in tableToAlter.columns:
            if (columna._name == colAMod):
                bandera = True
                columna._notNull = True
                break

        if not bandera:
            desc = f": Undefined column in alter not null ()"
            ErrorController().add(26, 'Execution', desc, 0, 0)
            return
        bandera = False
        typeChecker.writeFile()
Ejemplo n.º 14
0
    def eliminarColumna(self, nombreTabla, nombreColumna):
        typeChecker = TypeChecker()
        bandera = False
        tableToAlter = typeChecker.searchTable(SymbolTable().useDatabase,
                                               nombreTabla)

        for columna in tableToAlter.columns:
            if (columna._name == nombreColumna):
                bandera = True
                # typeChecker.deleteColumn(tableToAlter,columna,0,0)
                break

        if not bandera:
            desc = f": Undefined column in alter drop column ()"
            ErrorController().add(26, 'Execution', desc, 0, 0)
            return
        bandera = False
        pass
Ejemplo n.º 15
0
    def process(self, instrucction):

        typeChecker = TypeChecker()
        bandera = False
        tableToAlter = typeChecker.searchTable(SymbolTable().useDatabase,
                                               instrucction)

        for columna in tableToAlter.columns:
            if (columna._name == self._oldName):
                bandera = True
                columna._name = self._newName
                break

        if not bandera:
            desc = f": Undefined column in rename column ()"
            ErrorController().add(26, 'Execution', desc, 0, 0)
            return
        bandera = False
        typeChecker.writeFile()
Ejemplo n.º 16
0
    def searchTableIndex(self, tabla, linea, column):
        database_id = SymbolTable().useDatabase
        lista = []
        if not database_id:
            desc = f": Database not selected"
            ErrorController().add(4, 'Execution', desc, linea,
                                  column)  # manejar linea y columna
            return False
        # Base de datos existe --> Obtener tabla
        table_tp = TypeChecker().searchTable(database_id, tabla)
        if not table_tp:
            desc = f": Table does not exists"
            ErrorController().add(4, 'Execution', desc, linea,
                                  column)  # manejar linea y columna
            return False
        table_cont = DataController().extractTable(tabla, linea, column)

        headers = TypeChecker().searchColumnHeadings(table_tp)
        return True
Ejemplo n.º 17
0
    def addInherits(self, nameChildTable, nameParentTable):
        typeChecker = TypeChecker()
        tablaPadre = typeChecker.searchTable(SymbolTable().useDatabase,
                                             nameParentTable)
        tablaHija = typeChecker.searchTable(SymbolTable().useDatabase,
                                            nameChildTable)

        # La tabla de la que hereda no existe
        if tablaPadre == None:
            desc = f": parent table dont exists"
            ErrorController().add(27, 'Execution', desc, 0, 0)
            self._can_create_flag = False
            return

        for colPar in tablaPadre._colums:
            # Vamos a insertar en la hija
            validarCol = typeChecker.createColumnTable(tablaHija, colPar, 0, 0)
            # Si es una columna repetida entonces no puede crear la tabla
            if validarCol == None:
                self._can_create_flag = False
                return
Ejemplo n.º 18
0
    def validateValues(self, array_values: list):
        database_id = SymbolTable().useDatabase
        table_tp = TypeChecker().searchTable(database_id, self.table.alias)
        headers = TypeChecker().searchColumnHeadings(table_tp)
        if len(headers) != len(array_values):
            desc = "Error Datos incompletos"
            ErrorController().add(28, 'Execution', desc, self.line, self.column)
            return False

        checker = CreateTB(None, None, None, None)
        dic = dict(zip(headers, array_values))
        for index, name_col in enumerate(headers):
            column = TypeChecker().searchColumn(table_tp, name_col).__dict__
            is_correct = checker.validateType(
                column['_dataType'], array_values[index], False)
            if not is_correct:
                desc = f'Valor no valido para la columna {name_col}'
                ErrorController().add(9, 'Execution', desc, self.line, self.column)
                return False
            if not realizeCheck(column, dic, self.line, self.column):
                return False
        return True
Ejemplo n.º 19
0
    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)
Ejemplo n.º 20
0
    def process(self, instruction):
        typeChecker = TypeChecker()

        print('')
        print('VAMOS A MODIFICAR LA SIGUIENTE TABLA')
        print(self._tablaAModificar)

        existTable = typeChecker.searchTable(SymbolTable().useDatabase,
                                             self._tablaAModificar)

        # validate if the table to alter exists
        if existTable == None:
            desc = f": Undefined table in alter table"
            ErrorController().add(27, 'Execution', desc, 0, 0)
            return

        print('y estos son los cambios')
        #  Cambio puede ser un add    (column,check,constraint_unique,foreign_key)
        #                   un alter
        #                   un drop
        #                   un rename
        for cambio in self._listaCambios:
            cambio.process(self._tablaAModificar)
Ejemplo n.º 21
0
    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)
Ejemplo n.º 22
0
    def agregarFk(self, listaCols, nombreTabla, listaTablasCols, tablaAAlter):

        typeChecker = TypeChecker()

        # the len of the cols must be de same
        if len(listaCols) != len(listaTablasCols):
            desc = f": cantidad of params in foreign() != "
            ErrorController().add(36, 'Execution', desc, 0, 0)
            return

        existForeingTable = typeChecker.searchTable(SymbolTable().useDatabase,
                                                    nombreTabla)
        tableToAlter = typeChecker.searchTable(SymbolTable().useDatabase,
                                               tablaAAlter)

        # validate if the foreign table exists
        if existForeingTable == None:
            desc = f": Undefined table in foreign key ()"
            ErrorController().add(27, 'Execution', desc, 0, 0)
            return

        # validate if the columns exists in the foreign table
        for coli in listaTablasCols:
            if typeChecker.searchColumn(existForeingTable, coli) == None:
                desc = f": Undefined col in table in foreign key ()"
                ErrorController().add(26, 'Execution', desc, 0, 0)
                return

        bandera = False
        for x in range(0, len(listaCols)):
            for columna in tableToAlter.columns:
                if (columna._name == listaCols[x]):
                    bandera = True
                    columna._foreignKey = {
                        '_refTable': nombreTabla,
                        '_refColumn': listaTablasCols[x]
                    }
                    break
            if not bandera:
                desc = f": Undefined column in alter foreign key ()"
                ErrorController().add(26, 'Execution', desc, 0, 0)
                return
            bandera = False

        typeChecker.writeFile()
Ejemplo n.º 23
0
    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)
Ejemplo n.º 24
0
    def extractRangeTable(self, name: str, number: int, lower: any, upper: any,
                          noLine, noColumn) -> list:  # TODO terminar
        """
        Method to get a range of records from a table

        :param name: The name of table
        :param number: The column number

        :param noLine: The instruction line
        :param noColumn: The instruction column
        :return: Returns a list of records
        """
        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)
Ejemplo n.º 25
0
    def process(self, instrucction):
        typeChecker = TypeChecker()
        database = typeChecker.searchDatabase(self._properties['id'])

        if database:
            if self._properties['if_not_exists']:
                return

            if self._replace:
                typeChecker.deleteDatabase(database.name, self._noLine,
                                           self._noColumn)

        # TODO Verificar permisos y modo
        database = Database(self._properties['id'])

        for permits in self._properties['listpermits']:
            if 'MODE' in permits:
                database.mode = permits['MODE']

        typeChecker.createDatabase(database, self._noLine,
                                   self._noColumn)
Ejemplo n.º 26
0
    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)
Ejemplo n.º 27
0
 def process(self, instrucction):
     typeChecker = TypeChecker()
     typeChecker.deleteTable(self._table_name, self._noLine, self._noColumn)
Ejemplo n.º 28
0
 def process(self, instrucction):
     if self._alterType == 1:
         TypeChecker().updateDatabase(self._oldValue, self._newValue,
                                      self._noLine, self._noColumn)
     elif self._alterType == 2:
         pass
Ejemplo n.º 29
0
class TypeCheckerReport(object):
    def __init__(self):
        self._typeChecker = TypeChecker()
        self._data = ''

    def generateReport(self):
        self._data = 'digraph {\n\ttbl [\n\tshape=plaintext\n\tlabel=<'
        self._data += '\n\t\t<table border=\'0\' cellborder=\'1\' color=\'#324960\' cellspacing=\'0\'>'
        self.generateDatabases()
        self._data += '\n\t\t</table>\n\t>];\n}'
        return self._data

    def generateDatabases(self):
        databases = self._typeChecker.getList()

        for db in databases:
            self._data += '\n\t\t\t<tr>'
            self._data += '\n\t\t\t\t<td bgcolor="#324960" colspan=\'10\' SIDES=\"TB\">'
            self._data += f"\n\t\t\t\t\t<font color=\"white\">DATABASE: {db.name}</font>"
            self._data += '\n\t\t\t\t</td>'
            self._data += '\n\t\t\t\t<td bgcolor="#324960" colspan=\'1\' SIDES=\"TB\">'
            self._data += f"\n\t\t\t\t\t<font color=\"white\">MODE: {db.mode}</font>"
            self._data += '\n\t\t\t\t</td>'
            self._data += '\n\t\t\t</tr>'
            self.generateTables(db)
            self._data += '\n\t\t\t<tr>\n\t\t\t\t<td colspan=\'11\' SIDES="T"> </td>\n\t\t\t</tr>'

    def generateTables(self, database):
        for tb in database.tables:
            self._data += '\n\t\t\t<tr>\n\t\t\t\t<td bgcolor="#4fc3a1" colspan=\'11\' SIDES="LR">'
            self._data += f"\n\t\t\t\t\t<font color=\"white\">TABLE: {tb.name}</font>"
            self._data += '\n\t\t\t\t</td>\n\t\t\t</tr>'
            self.generateColumns(tb)

    def generateColumns(self, table):

        self._data += '\n\t\t\t<tr>'
        self.dataHeaderCol('Number')
        self.dataHeaderCol('Name')
        self.dataHeaderCol('Data Type')
        self.dataHeaderCol('Length')
        self.dataHeaderCol('Default')
        self.dataHeaderCol('Not Null')
        self.dataHeaderCol('Unique')
        self.dataHeaderCol('Constraint')
        self.dataHeaderCol('Check')
        # self.dataHeaderCol('Auto Increment')
        self.dataHeaderCol('Primary Key')
        self.dataHeaderCol('Foreign Key')
        self._data += '\n\t\t\t</tr>'

        for col in table.columns:
            self._data += '\n\t\t\t<tr>'
            self.dataCol(col.number)
            self.dataCol(col.name)
            self.dataCol(col.dataType)
            self.dataCol(col.length)
            self.dataCol(col.default)
            self.dataCol(col.notNull)
            self.dataCol(col.unique)
            self.dataCol(col.constraint)
            self.dataCol(col.check)
            # self.dataCol(col.autoincrement)
            self.dataCol(col.primaryKey)
            self.dataCol(col.foreignKey)
            self._data += '\n\t\t\t</tr>'

    def dataHeaderCol(self, name):
        self._data += f"\n\t\t\t\t<td SIDES=\"B\"><b> {name} </b></td>"

    def dataCol(self, data):
        self._data += f"\n\t\t\t\t<td SIDES=\"B\">{data}</td>"
Ejemplo n.º 30
0
 def __init__(self):
     self._typeChecker = TypeChecker()
     self._data = ''