A VS Code extension that provides SQL syntax highlighting and formatting for SQL code embedded in Python strings, including support for Jupyter notebooks.
Features
SQL Syntax Highlighting
Highlights SQL syntax within Python triple-quoted strings marked with --sql
Supports both regular strings and f-strings
Works in .py files and Jupyter notebooks (.ipynb)
No bleeding of syntax highlighting beyond string boundaries
SQL Formatting
Formats SQL code with customizable rules
Accessible via Command Palette or keyboard shortcut
Smart formatting that preserves BigQuery-specific syntax
Reload VS Code window: Cmd+Shift+P → "Developer: Reload Window"
Usage
Syntax Highlighting
Mark your SQL strings with --sql comment:
# Regular strings
query = """--sql
SELECT * FROM users
WHERE status = 'active'
"""
# F-strings with variables
user_id = 123
query = f"""--sql
SELECT * FROM users
WHERE id = {user_id}
"""
SQL Formatting
Format your SQL using:
Keyboard Shortcut: Shift+Alt+F (when in .sql, .py, or .ipynb files)