Bjorn Hansen
Bjorn Hansen

Reputation: 389

Way to have SQL intellisense or autocompletion inside code strings in Visual Studio Code?

In JetBrains IDE's like PHPStorm this is a built-in feature. E.g. in the code below, editing the SQL inside the string would autocomplete as SQL and suggest table/column names from an active database connection.

query("SELECT * FROM users LIMIT 50");

When using Visual Studio Code or similar editors like Theia, this functionality would be supplied by a plugin. Unfortunately, I haven't come across a plugin on the marketplace that has this feature. Some have autocomplete for .sql files, but not inline SQL. It's hard to believe this isn't possible yet in such a popular editor.

Has anyone found a solution for this?

Plugins I've tried so far (I'm specifically looking for Postgres):

Upvotes: 27

Views: 17465

Answers (5)

SENKEN
SENKEN

Reputation: 21

I've created exactly the extension: sqlsurge you are looking for! This extension supports Postgres, MySQL, and so on. Custom functions are not supported now but comming soon! Try it!

Also I wrote english article: I created a VSCode extension to make developing raw SQL queries incredibly easy [TypeScript+Rust+WASM].

Upvotes: 2

Richard 365
Richard 365

Reputation: 11

You can by using the SQL Server (mssql) VS Code extension. The extension gives IntelliSense for SQL within JavaScript and TypeScript files. You just need to establish a connection to your database, and you should get inline SQL autocomplete and suggestions.

Upvotes: 0

kevlened
kevlened

Reputation: 11226

The closest I've found is the Inline SQL extension. It uses a connection to a db to lint inline SQL and it supports postgres.

It doesn't seem to support intellisense, but it is open source under an MIT license if you'd like to extend it or use it for inspiration.

Upvotes: 1

Mike Hoxter
Mike Hoxter

Reputation: 46

I use it on Visual Studio and it works well, but Github Copilot works well. You have to pay for it unfortunately, but it's probably the best intellisence I've seen.

Upvotes: 0

You can use this extension. Supports Python, Go, Rust, JS, TS, Ruby, Java, C# and PHP.

Upvotes: 0

Related Questions