Reputation: 389
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
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
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
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
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
Reputation: 359
You can use this extension. Supports Python, Go, Rust, JS, TS, Ruby, Java, C# and PHP.
Upvotes: 0