How to Connect Redshift to VS Code in PostgreSQL

Galaxy Glossary

How do I connect Amazon Redshift to VS Code?

Use a PostgreSQL-compatible connection string with an SQL client extension (e.g., SQLTools) to query Amazon Redshift directly from VS Code.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

What do I need before connecting VS Code to Redshift?

Ensure you have: 1) Amazon Redshift endpoint, port (default 5439), database name, user, and password; 2) VS Code installed; 3) an SQL client extension such as SQLTools or Database Client; 4) PostgreSQL driver selected inside the extension because Redshift speaks the PostgreSQL wire protocol.

How do I install the required VS Code extension?

Open VS Code → Extensions panel → search “SQLTools” → click Install.After install, open Command Palette (⌘/Ctrl + Shift + P) → “SQLTools: Install Driver” → choose “PostgreSQL/Redshift”.

How do I create a Redshift connection profile?

Inside VS Code, press ⌘/Ctrl + Shift + P → “SQLTools: Add New Connection”. Pick PostgreSQL/Redshift. Fill the form with host, port, database, user, and password.Optionally add ssl=true for encrypted traffic or timeout=30 seconds.

Sample JSON profile

{ "name": "Prod-Redshift", "driver": "PostgreSQL", "host": "example-cluster.abc123.us-east-1.redshift.amazonaws.com", "port": 5439, "database": "analytics", "username": "galaxy_read", "password": "••••", "ssl": true }

Which connection string formats work?

SQLTools accepts URI or key-value. URI format: postgresql://user:pass@host:port/database?ssl=true&connect_timeout=10. Replace each placeholder with your Redshift values.

How do I test the connection?

In SQLTools sidebar, right-click the new profile → Test Connection. A green check confirms success.If it fails, re-check security-group rules, username/password, and SSL setting.

How do I run queries once connected?

Create a .sql file, select your connection in the bottom bar, highlight SQL, press ⌘/Ctrl + Enter. Results show in an embedded panel with tabs for Results, Messages, and Query Plan.

Can I parameterize and save queries?

SQLTools supports snippets and .sql files under version control.Use Galaxy Collections for sharing endorsed queries with teammates to avoid copy-pasting in Slack.

How do I disconnect?

Right-click the connection → Disconnect. Connections auto-close after inactivity if idleTimeout is set in the profile.

Best practices for Redshift × VS Code

Use IAM-based passwords rotated via AWS Secrets Manager. Limit Redshift user to read-only if you only run analytics. Store connection profiles in settings.json but exclude passwords from Git.

.

Why How to Connect Redshift to VS Code in PostgreSQL is important

How to Connect Redshift to VS Code in PostgreSQL Example Usage


-- Total revenue last 30 days
SELECT o.order_date,
       SUM(oi.quantity * p.price) AS total_revenue
FROM   Orders    o
JOIN   OrderItems oi ON oi.order_id = o.id
JOIN   Products   p ON p.id = oi.product_id
WHERE  o.order_date >= CURRENT_DATE - INTERVAL '30 days'
GROUP  BY o.order_date
ORDER  BY o.order_date DESC;

How to Connect Redshift to VS Code in PostgreSQL Syntax


URI syntax:
postgresql://<user>:<password>@<host>:<port>/<database>?ssl=<true|false>&connect_timeout=<seconds>

Key-value JSON (SQLTools):
{
  "name": "<friendly name>",
  "driver": "PostgreSQL",
  "host": "<host>",
  "port": <port>,
  "database": "<database>",
  "username": "<user>",
  "password": "<password>",
  "ssl": <true|false>,
  "connectTimeout": <seconds>
}

E-commerce example: connect as readonly user to run revenue query on Orders & OrderItems tables.

Common Mistakes

Frequently Asked Questions (FAQs)

Do I need a separate Redshift driver?

No. The PostgreSQL driver works because Redshift implements the same protocol, but choosing the Redshift-optimized driver disables unsupported features like SAVEPOINT.

Can I use IAM authentication in VS Code?

Yes. Generate a temporary auth token with AWS CLI aws redshift get-cluster-credentials and place it in the password field; set ssl=true.

How do I enable auto-completion for Redshift objects?

After connecting, click the refresh icon in SQLTools Explorer. The extension pulls schema metadata so IntelliSense works across Customers, Orders, and more.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
BauHealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.