Connecting to a Postgres database with Azure Data Studio
- data
- 2024-05-09
- 2 minutes to read
- postgres
- azure data studio
- docker
Table of Contents
Introduction
I have been working with a Postgres database in a docker container recently to get to grips with dbt. I typically work in the world of SQL Server and so I have Azure Data Studio installed on my Mac. I was delighted to discover that Azure Data Studio is capable of connecting to a Postgres database. Here is how to do it…
Install Azure Data Studio
Firstly, you need to install Azure Data Studio. You can download it from Microsoft.
Install the Postgres extension
Once you have installed Azure Data Studio, you need to install the Postgres extension. You can do this by clicking on the Extensions icon on the left-hand side of the screen and searching for Postgres
or from the marketplace.
Create a new connection
Once you have installed the extension, you can create a new connection by clicking on the New Connection icon on the left-hand side of the screen. You will need to enter the following details:
- Switch Connection type to
PostgreSQL
. - Enter the Server name.
- Enter the user name and password.
- Enter the database name.
If you set up the Postgres container on a non-default port, you can set that port in the advanced settings.
Connect to the database
Once you have entered the details, you can click on the Connect button. If you have entered the details correctly, you should see the database in the Object Explorer on the left-hand side of the screen. You can also create databases, tables, and run queries from here.
Unresponsive
The extension is still in preview and so it is a bit buggy. I have found that sometimes I need to close and reopen Azure Data Studio to get it to connect to the database as it will just hang whilst refreshing the connection in the object explorer. I am sure there are better tools out there for connecting to Postgres databases, but as a way to just get started quickly to evaluate dbt with the tools that I am already comfortable with, it’s ideal.
Wrapping Up
I have shown you how to connect Azure Data Studio to a Postgres database. vscode / Azure Data Studio are such flexibile tools it’s great to be able to work with a multitude of different languages, databases, and extensions all in once place.