Inline_sql_syntax

Highlight and lint inline SQL strings.
Alternatives To Inline_sql_syntax
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Tidb33,72168101a day ago1,289April 07, 20223,877apache-2.0Go
TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://tidbcloud.com/free-trial
Metabase31,887
a day ago1June 08, 20222,776otherClojure
The simplest, fastest way to get business intelligence and analytics to everyone in your company :yum:
Dbeaver31,315
a day ago1,782apache-2.0Java
Free universal database tool and SQL client
Redash22,871
3 days ago2May 05, 2020773bsd-2-clausePython
Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data.
Directus20,78650a day ago55September 22, 2022360gpl-3.0TypeScript
The Modern Data Stack 🐰 — Directus is an instant REST+GraphQL API and intuitive no-code data collaboration app for any SQL database.
Shardingsphere18,1668a day ago7June 04, 2020593apache-2.0Java
Ecosystem to transform any database into a distributed database system, and enhance it with sharding, elastic scaling, encryption features & more
Knex17,37018,0962,788a day ago248August 31, 2022807mitJavaScript
A query builder for PostgreSQL, MySQL, CockroachDB, SQL Server, SQLite3 and Oracle, designed to be flexible, portable, and fun to use.
Cube14,809
a day ago752otherRust
📊 Cube — The Semantic Layer for Building Data Applications
Dolt14,4702a day ago214May 19, 2022266apache-2.0Go
Dolt – Git for Data
Mysql13,1654,8927,8152 days ago49March 25, 2022106mpl-2.0Go
Go MySQL Driver is a MySQL driver for Go's (golang) database/sql package
Alternatives To Inline_sql_syntax
Select To Compare


Alternative Project Comparisons
Readme

Inline SQL shield

Also available in Open VSX Registry

python

Highlight and lint inline SQL strings. Supported languages are Python, Go, JavaScript, TypeScript, Ruby, Java, C#, Rust, PHP, Lua.

Syntax highlighting works for strings starting with --sql or any of the SELECT, INSERT, INTO, DELETE, UPDATE, CREATE TABLE.

Also works with ES6 Template Strings:

const query = sql`
    select * from book;
`;

Linting and diagnostics powered entirely by awesome joereynolds/sql-lint and works for multiline strings that start with either `--sql (backtick followed by --sql), "--sql or """--sql.

Contributors

jwhitaker-swiftnav
jwhitaker-swiftnav
Wild-W
Connor Bren
tamasfe
Ferenc Tams
nossrannug
Gunnar Sv Sigurbjrnsson
JonathanWolfe
Jon Wolfe
titouancreach
Titouan CREACH

Safety

The proper way to sanitize data for insertion into your database is to use placeholders for all variables to be inserted into your SQL strings. In other words, NEVER do this (Python example):

query = f"INSERT INTO foo (bar, baz) VALUES ( {variable1}, {variable2} )";

Instead, use $ placeholders (or ? in some databases):

query = "INSERT INTO foo (bar, baz) VALUES ( $1, $2  )";

And then pass the variables to be replaced when you execute the query. For example with pgx (Go example):

err = conn.QueryRow(
    context.Background(),
    "select name, weight from widgets where id=$1",
    42,
).Scan(&name, &weight)

Integration with real database

Integration with real database is available and controlled through VSCode options:

{
    "inlineSQL.enableDBIntegration": true,
    "inlineSQL.dbDriver": "postgres",
    "inlineSQL.dbHost": "localhost",
    "inlineSQL.dbPort": 5432,
    "inlineSQL.dbUser": "postgres",
    "inlineSQL.dbPassword": "postgres"
}

Examples

Python

python

JavaScript/TypeScript

js

Go

go

go

Python JavaScript/TypeScript
Ruby Java

Limitations

Semantic highlighting

Highlighting does not work with semantic token highlighting enabled (feature provided by some LSP servers).

Currently gopls semantic token highlighting (option gopls.ui.semanticTokens - off by default) overrides extension's syntax.

gopls

{
    "gopls.ui.semanticTokens": false
}

rust-analyzer

{
    "rust-analyzer.highlighting.strings": false
}

C#

{
    "csharp.semanticHighlighting.enabled": false
}

Motivation

This small extension is meant to help those who don't use ORM and don't like SQL builders like squirrel, but still want inline sql in their code to be something more than magic strings, helping to avoid small bugs and typos almost instantly.

Related

Popular Sql Projects
Popular Mysql Projects
Popular Data Processing Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Typescript
Mysql
Postgresql
Sql
Vscode
Vscode Extension