I’ve been working as a database engineer for over a decade, engineering enterprise data platforms. During the beginning of my career in early 2000, I chose the ‘safe’ path of being a DBA believing that relational systems being universal containers for storing critical data will never change. I started learning relational technologies like Oracle, MS-SQL, and eventually also learned Open Source systems including PostgreSQL & MySQL.
- Connect to PostgreSQL instances
- View object DDL with ‘Go to Definition’ and ‘Peek Definition’
- Write queries with IntelliSense
- Run queries and save results as JSON, csv, or Excel
Using VS Code PostgreSQL extension
- Open the Command Palette
Ctrl + Shift + P(On mac use
⌘ + Shift + P)
Search and select
PostgreSQL: New Query
In the command palette, select
Create Connection Profile. Follow the prompts to enter your Postgres instance hostname, database, username, and password.
You are now connected to your Postgres database. You can confirm this via the Status Bar (the ribbon at the bottom of the VS Code window). It will show your connected hostname, database, and user.
Now, let’s try to query database.
Type a query ex.
SELECT * FROM pg_stat_activity;
6. You can also save the query results as JSON, CSV or Excel.
So now, you can seamlessly code for PostgreSQL from Microsoft VS Code without switching screens, leverage powerful intellisense and execute queries.
IMP NOTE: Result windows from queries won´t show up again after being closed. This is bug with current version and is being worked by dev team. Workaround is either to keep the result window Open Or close / re-open the VS code window.