Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code SQL Syntax Highlighting in .py Files

I am switching over from atom to VSCode and finding it to be a way better experience for (mostly) python.

One thing I can't seem to work out is that the python syntax highlighting on atom recognised SQL in strings and highlighted it.

VSCode Atom

I can't seem to find an extension for VSCode to do the same thing.

Does one exist or is there a way to get this highlighting in VSCode?

like image 840
James Maguire Avatar asked Jul 26 '18 08:07

James Maguire


2 Answers

The best solution I found so far is this extension: https://github.com/ptweir/python-string-sql

It highlights multi quoted strings that start with --sql and end with ;, such as this one:

query = f"""--sql
SELECT * FROM mytable;
"""
like image 115
Rotareti Avatar answered Sep 19 '22 21:09

Rotareti


Unfortunately, this doesn't seem possible yet. But vote here: https://github.com/MagicStack/MagicPython/issues/27

like image 23
Megadest Avatar answered Sep 20 '22 21:09

Megadest