'Processes SQL text consisting of one or more statements
:param sql: SQL to execute
:param bindings: bindings for the *sql*
:param internal: If True then this is an internal execution
(eg the .tables or .database command).  When executing
internal sql timings are not shown nor is the SQL echoed.
:param summary: If not None then should be a tuple of two
items.  If the ``sql`` returns any data then the first item
is printed before the first row, and the second item is
printed after the last row.  An example usage is the .find
command which shows table names.'

def process_sql(self, sql, bindings=None, internal=False, summary=None):

    cur = self.db.cursor()
    state = {'newsql': True, 'timing': None}
    def et(cur, sql, bindings):
        state['newsql'] = True
        if ((not internal) and self.timer):
            if state['timing']:
                self.display_timing(state['timing'], self.get_resource_usage())
        if ((not internal) and self.echo):
            if bindings:
                self.write(self.stderr, ('%s    [%s]\n' % (sql, bindings)))
            else:
                self.write(self.stderr, (sql + '\n'))
        if ((not internal) and self.timer):
            state['timing'] = self.get_resource_usage()
        return True
    cur.setexectrace(et)
    try:
        for row in cur.execute(sql, bindings):
            if state['newsql']:
                if summary:
                    self._output_summary(summary[0])
                cols = [h for (h, d) in cur.getdescription()]
                self.output(True, cols)
                state['newsql'] = False
            self.output(False, row)
        if ((not state['newsql']) and summary):
            self._output_summary(summary[1])
    except:
        if ((not internal) and self.echo):
            tb = sys.exc_info()[2]
            last = None
            while tb:
                last = tb.tb_frame
                tb = tb.tb_next
            if (last and (last.f_code.co_name == 'sqlite3_prepare') and last.f_code.co_filename.endswith('statementcache.c') and ('sql' in last.f_locals)):
                self.write(self.stderr, (last.f_locals['sql'] + '\n'))
        raise
    if ((not internal) and self.timer):
        self.display_timing(state['timing'], self.get_resource_usage())
