Connecting to Visual Studio Code with PostgreSQL: Running Queries

emmy adigun
2 min readJan 22, 2022
Image Source: ilovefreesoftware.com

This article will explain a powerful extension tool available on VS code for DB(Postgres, AWS RDS) connection and running SQL queries.

Visual Studio Code is a lightweight source code editor which runs on your desktop and is available for Windows, macOS, and Linux. Features include support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git.

Visual Studio Code has a wide variety of plugins, including many for PostgreSQL.

  1. Download VS Code
    Visit https://code.visualstudio.com/ to download

2. Install the PostgreSQL Server Extension
Go to the Tools section on the left and click the ‘‘Extensions’’ icon. Type “PostgreSQL” and several results will be displayed. Select the option by Chris Kolkman and click install. Once installed, the PostgreSQL Explorer icon appears on the tools bar on the left

3. Managing Connections
PostgreSQL connection can be added in the explorer or via the command palette. To connect via the explorer,
- click the installed PostgreSQL Explorer icon
- Click the plus(+) sign at the top.
- Follow the prompt by entering the hostname of the Database e.g localhost or URL, PostgreSQL username and password for authentication, port number, and connection type.

Viola!!! you are connected. You can then select the database you want to query.

Image Source: FAUN Publication

4. Type and Run your Queries
On the editor, you can type and run your queries. Type out your query (you will get auto-complete options as you type) and right-click and select Execute Query. You will see the results of your query in the right-hand pane.

Image Souce: FAUN Publication

The End!!

--

--