Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions 3 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Install `python-string-sql` from extensions (`ctrl + shift + x` or `cmd + shift

## Usage

Insert `--sql`, `--beginsql`, or `--begin-sql` at the beginning of the part of the string you would like highlighted and a semicolon, `--endsql`, or `--end-sql` at the end of the highlighted section.
In a `""" multi-line """` or `f""" f-string multiline """` string, use a `select`, `with`, or `-- sql-comment`, and the string will then be treated as embedded SQL.

### Snippets
begin typing `sql` and the autocomplete snippet will appear:
Expand All @@ -25,7 +25,6 @@ begin typing `sql` and the autocomplete snippet will appear:
cmd+s (or ctrl+s on mac) - Insert the following snippet:
```
"""
--sql
SELECT
;
"""
Expand Down
Binary file modified BIN -75.4 KB (30%) docs/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion 1 docs/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
cur = conn.cursor()

query = """
--begin-sql
SELECT last_name,
start_day,
COUNT(*) AS num_entries
Expand Down
1 change: 0 additions & 1 deletion 1 snippets/python.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"prefix": "sql",
"body": [
"\"\"\"",
"--sql",
"${1| ,SELECT,WITH|}",
";",
"\"\"\""
Expand Down
18 changes: 8 additions & 10 deletions 18 syntaxes/highlight-sql-string.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@
"injectionSelector": "L:string.quoted.multi.python, L:meta.fstring.python - (comment.line.number-sign.python, punctuation.definition.comment.python)",
"patterns": [
{
"begin": "( *--sql| *--beginsql| *--begin-sql)",
Copy link
Copy Markdown

@cikay cikay Nov 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not recommend to remove the current identifiers. It would break all implementation. Add new ones but do not remove the current ones.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thanks for getting to this :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you are not maintainer haha. You're probably right but ill wait to hear from repo owner/member if they are still alive...

"end": "( *;| *--endsql| *--end-sql)",
"captures": {
"1": {
"name": "variable.parameter"
}
"name": "meta.embedded.sql",
"begin": "\\s*((?i)(select|with)|(--.*))",
"end": "(?=\"\"\")",
"beginCaptures": {
"2": { "name": "keyword.other.DML.sql" },
"3": { "name": "comment.line.double-dash.sql" }
},
"patterns": [
{
"include": "source.sql"
}
{ "include": "source.sql" }
]
}
],
"scopeName": "python-sql.injection"
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.