vim: higlight SQL inside python triple-quote string
<p>I'm trying to highlight SQL queries inside python triple-quote strings in Vim. Using this <a href="https://stackoverflow.com/q/29791199">question</a> I have a <code>pysql.vim</code> file containing:</p>

<pre><code>if exists('b:current_syntax')
finish
endif

" Load Python syntax at the top level
runtime! syntax/python.vim
unlet b:current_syntax

" Load SQL syntax
syn include @SQL syntax/sql.vim

syntax region sqlSnippet start=/\zs\v(SELECT|FROM|AND|WHERE|OR|ON|GROUP BY|ORDER BY)/ end=/\ze'''/ contains=@SQL containedin=pythonString

let b:current_syntax = 'pysql'
</code></pre>

<p>However when I run <code>set syntax=pysql</code> in the following <code>foo.py</code> file</p>

<pre><code>def get_first_events_after_install(application_id, os, event_id,
                                   year_start, month_start, day_start,
                                   year_end, month_end, day_end,
                                   perform=False):

    query = \
        '''SELECT event_id, counter, name FROM
        (
        -- This selects event_ids and counts number of occurrences for a
        -- specific in a specific time frame
        SELECT event_id, COUNT(1) as counter FROM fault.all_events_monthly
        WHERE month_partition
            BETWEEN '201511' AND '201601'
            AND app_partition IN (434)
            AND ref_type_partition IN ('apple_ifa')
        GROUP by event_id
        ) t_counter
    INNER JOIN
        (
            --  This selects events names and along event_id
            SELECT id, name from mysql.ruby.events
        ) t_name
    ON t_counter.event_id = t_name.id
    ORDER BY counter DESC'''.\
        format(month_part=month_partitions, os_part=os_partitions,
               ys=year_start, ms=month_start, ds=day_start,
               ye=year_end, me=month_end, de=day_end, app_id=application_id,
               ev_id=event_id)
</code></pre>

<p>The code before and after the string query is also highlighted as SQl (you can see this in the image below). So my question is: how do I higlight SQL code only inside a triple (or triple-double) quote string? Thanks in advance.</p>

<p><a href="https://i.stack.imgur.com/b87HJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b87HJ.png" alt="enter image description here"></a></p>