Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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):

  • SQLTools
  • PostgreSQL - privately maintained
  • PostgreSQL - abandonware by Microsoft
like image 234
bjorn Avatar asked Sep 09 '25 11:09

bjorn


2 Answers

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].

like image 152
SENKEN Avatar answered Sep 11 '25 08:09

SENKEN


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.

like image 39
kevlened Avatar answered Sep 11 '25 09:09

kevlened