Use the Microsoft PostgreSQL extension or SQLTools to open a secure connection in VS Code, then run, save, and share queries directly from the editor.
Running SQL inside VS Code keeps code, queries, and version control in one place, improves productivity, and lets you leverage extensions like Galaxy’s AI copilot to write faster SQL.
Install “PostgreSQL” by Microsoft (ID: ms-azuretools.vscode-postgresql). Alternatively, install SQLTools plus the SQLTools PostgreSQL/Redshift driver for multi-DB workflows.
Open the Command Palette → “PostgreSQL: New Connection”. Enter host, port, database, user, and password.Save the profile so it lives in settings.json
.
Yes. In the connection dialogue, set Password → ${env:PGPASSWORD}
. Store PGPASSWORD
in your OS keychain or .env
file for safer credential management.
Use postgresql://user:password@host:port/database?sslmode=require
. The extension parses this string to fill its fields automatically.
Open a .sql
file → select text → press F5 (or click “Run”).Results appear in an inline Result Grid you can copy, save, or export as CSV.
Yes. Use :variable
placeholders, then provide values when prompted. Example: SELECT * FROM Orders WHERE customer_id = :cust_id;
Use Galaxy Collections or commit .sql
files to Git. The PostgreSQL extension stores saved connections locally, so share only the SQL, not credentials.
Enable SSL (sslmode=require
), avoid hard-coding passwords, use least-privilege DB roles, and rotate credentials periodically.
.
Yes, the Microsoft PostgreSQL extension is open-source and free to use inside VS Code.
Absolutely. Create separate connection profiles for staging, production, and local databases. Profiles appear in the Explorer tree.
Yes. Provide sslcert
, sslkey
, and sslrootcert
parameters in the connection string for full certificate-based authentication.