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.
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?
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; """
Right now it doesn't support
f-strings but there is (as of the time writing) an un-merged pull-request to fix it. So there may be f-string support soon.
Language Support in Visual Studio Code, MagicPython correctly highlights all Python 3 syntax features, or directly by adding "Python" to "ignored_packages" in the settings file). They should be no more difficult to read at a glance than other code or comments. Terminal Color and Style Highlighting for VS Code. This extension provides highlighting for terminal color escape sequences in the editor. The colors and styles can be customized via the configuration and light / dark theming is supported. The included preview feature can be used to view the source file like it would be shown in a terminal.
Unfortunately, this doesn't seem possible yet. But vote here: https://github.com/MagicStack/MagicPython/issues/27
Similarly to @Rotareti's suggested extension, I am working on my own twist of it, that fits my personal needs.
It activates sql highlighting when sees one of the three starting keywords in multiline string (multiline starting with
f"""). Highlighting is deactivated when multiline string ends.
Only real limitation is that the keyword has to be in first line of string.
I have not published my package yet, but you can find it here: https://github.com/uogiukas/python-string-sql
--sql to start highlight just does not fit me since I have to go through a lot of other peoples' or my own old code where no such comment exists.
Highlight String Code, The extension makes VS Code an excellent Python editor, and works on any In the text editor: right-click anywhere in the editor and select Run Python File in� Any custom file extension can be associated with standard syntax highlighting with custom files association in User Settings as follows. Note that this will be a permanent setting. In order to set for the current session alone, type in the preferred language in Select Language Mode box (without changing file association settings)
Python in Visual Studio Code, in the settings, for example, when associating file extensions to a language: through the languages configuration point in the extension's package.json file: Python, python SCSS, scss (syntax using curly brackets), sass (indented syntax ) SQL, sql. Swift, swift. TypeScript, typescript. TypeScript React, typescriptreact. Connect to SQL databases, type T-SQL code, execute T-SQL code, view results, and save results as JSON or CSV files. While typing T-SQL code, you get rich T-SQL language features like T-SQL IntelliSense (code completion), syntax highlighting, linting, code navigation and code snippets.
Visual Studio Code language identifiers, SQL highlighting in Python multiline strings for VS Code. Adds syntax highlight support for python multiline SQL strings in VS Code. Install the mssql extension. The mssql extension for Visual Studio Code lets you connect to a SQL Server, query with Transact-SQL (T-SQL), and view the results.. In Visual Studio Code, select View > Command Palette, or press Ctrl+Shift+P, or press F1 to open the Command Palette.
python-string-sql, Environment data VS Code version: 1.33.1 Extension version (available Create or open a file with Python syntax; Type a string containing a� Python Django tutorial demonstrating IntelliSense, code navigation, and debugging for both code and templates in Visual Studio Code, the best Python IDE.