def extractFromSQLFile(self, filePointer, delimiter=";"):
        """
        Process an SQL file and extract all the queries sorted.

        :param filePointer: <io.TextIOWrapper> file pointer to SQL file
        :return: <list> list of queries
        """
        data = filePointer.read()

        # reading file and splitting it into lines
        dataLines = []
        dataLinesIndex = 0
        for c in data:
            if len(dataLines) - 1 < dataLinesIndex:
                dataLines.append("")

            if c == "\r\n" or c == "\r" or c == "\n":
                dataLinesIndex += 1
            else:
                dataLines[dataLinesIndex] = "{}{}".format(
                    dataLines[dataLinesIndex],
                    c
                )

        # forming SQL statements from all lines provided
        statements = []
        statementsIndex = 0
        for line in dataLines:
            # ignoring comments
            if line.startswith("--") or line.startswith("#"):
                continue

            # removing spaces
            line = line.strip()

            # ignoring blank lines
            if len(line) == 0:
                continue

            # appending each character to it's statement until delimiter is reached
            for c in line:
                if len(statements) - 1 < statementsIndex:
                    statements.append("")

                statements[statementsIndex] = "{}{}".format(
                    statements[statementsIndex],
                    c
                )

                if c == delimiter:
                    statementsIndex += 1

        return statements
def extractFromSQLFile ( self , filePointer , delimiter = ";" ) : data = filePointer . read ( ) dataLines = [ ] dataLinesIndex = 0 for c in data : if len ( dataLines ) - 1 < dataLinesIndex : dataLines . append ( "" ) if c == "\r\n" or c == "\r" or c == "\n" : dataLinesIndex += 1 else : dataLines [ dataLinesIndex ] = "{}{}" . format ( dataLines [ dataLinesIndex ] , c ) statements = [ ] statementsIndex = 0 for line in dataLines : if line . startswith ( "--" ) or line . startswith ( "#" ) : continue line = line . strip ( ) if len ( line ) == 0 : continue for c in line : if len ( statements ) - 1 < statementsIndex : statements . append ( "" ) statements [ statementsIndex ] = "{}{}" . format ( statements [ statementsIndex ] , c ) if c == delimiter : statementsIndex += 1 return statements
Process an SQL file and extract all the queries sorted.

        :param filePointer: <io.TextIOWrapper> file pointer to SQL file
        :return: <list> list of queries