Highlighting of SQL inside strings
See original GitHub issueThe stock Python package performs syntax highlighting inside strings containing SQL commands. That’s rather useful, even though the implementation might need some more work. In this example:
create = 'CREATE TABLE test (id INT, name TEXT);'
insert = 'INSERT INTO test VALUES (1, "Bob")'
in the second line, words recognized as SQL are highlighted, but not in the first one, where “CREATE TABLE” has the same color as the non-reserved names.
(Actually, as you can see, even Github’s Markdown does it, with exactly the same behavior, so perhaps something is wrong with the first line, although it does execute properly)
Do you consider this a useful addition?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:105
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Highlight String Code - Visual Studio Marketplace
Extension for Visual Studio Code - Highlight string as SQL, HTML, CSS or JS in most languages. 高亮内嵌的SQL,HTML, CSS或者JS.
Read more >Is it possible to have SQL syntax highlighting on strings ...
Hello, I'm trying to understand if it is possible to have (pl/PG)SQL syntax highlighting for queries that are on strings embedded in source...
Read more >Visual Studio Code SQL Syntax Highlighting in .py Files
It activates sql highlighting when sees one of the three starting keywords in multiline string (multiline starting with """ or f""" ).
Read more >Syntax Highlighting for SQL in Tagged Template Literals
In @databases you will use a lot of SQL strings inline within your TypeScript or JavaScript code. These strings are always "tagged" with...
Read more >Vim syntax highlighting for SQL strings inside Python code
In Python, I had to get slightly more clever: this will treat any triple quotes-delimited string as SQL if it starts with a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sublime uses not very sophisticated SQL indicator for triple quote highlighting:
\s*(?:SELECT|INSERT|UPDATE|DELETE|CREATE|REPLACE|ALTER|WITH)\b
Is it possible to implement this in MagicPython? Seems like a good feature, and used both in Atom and Sublime natively (does not work in VSCode).
Well, we have no plans for adding SQL highlighting. There are many cons/pros about this feature, see the above discussion.