Using Linqpad to Query Amazon Redshift Database Clusters

Looking for a quick and easy way to query an Amazon Redshift Database Cluster? I was and the first place I turned was to my favorite tool for this kind of thing, Linqpad. I was a bit dismayed to find that none has developed, that I could find, a Linqpad database driver for Redshift. Small note, there are a few Postresql options and Redshift is supposed to be Postresql compatible however, none of them seemed to work for Redshift.

Giving credit to the author of this article describing the use of Linqpad for connections to MS Access, I made a few tweaks and boom, I have a working way to connect to and query Redshift. So in the pay it forward spirit, I thought I'd share.

2026 Driver Update: AWS is retiring the legacy 1.x ODBC driver on June 1, 2026. Ensure you have installed the Amazon Redshift ODBC Driver 2.x. Unlike previous versions, the x64 driver is now the standard requirement for modern versions of LINQPad.
// PREREQUISITES:
// (1) Copy and paste this entire block of code into a Linqpad query window, 
//     no connection needed, and change language to C# Statement(s).
// (2) To use the .NET ODBC assembly, you'll have to press F4 then click on the 
//     "Additional Namespace Imports" tab. Add "System.Data.Odbc".
// (3) Install the Amazon Redshift ODBC Driver 2.x (x64). 
// (4) Update the query settings below.

// ***************** Update Settings Below *****************
string endpoint = " <endpoint> ";
string database = " <database_name> ";
string user     = " <username> ";
string pass     = " <password> ";
string port     = "5439"; // Default Redshift port

string table = "";
string query = "SELECT * FROM " + table; 
// ***************** End Update Settings *******************

string connectionString = $"Driver={{Amazon Redshift (x64)}}; Server={endpoint}; Database={database}; UID={user}; PWD={pass}; Port={port};";

using(OdbcConnection connection = new OdbcConnection(connectionString))
{
    Console.WriteLine($"Connecting to [{endpoint}]...");
    try
    {
        if (query.StartsWith("SELECT", StringComparison.OrdinalIgnoreCase))
        {
            using (OdbcDataAdapter adapter = new OdbcDataAdapter(query, connection))
            {   
                DataSet data = new DataSet();
                adapter.Fill(data, table);
                Console.WriteLine($"Found [{data.Tables[0].Rows.Count}] rows");
                data.Dump();
            }
        }
        else
        {
            connection.Open();
            using (OdbcCommand command = new OdbcCommand(query, connection))
            {
                var impactedRows = command.ExecuteNonQuery();
                Console.WriteLine($"[{impactedRows}] rows impacted");
            }
        }
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.ToString());
    }
}

Author’s Note: This article reflects my personal professional experience and opinions. While my insights are informed by my professional history, these views are my own and do not represent the official position of my former employer.

About the Author: Jacob Marks is an engineering leader with over 20 years of experience, including a decade at Amazon Web Services (AWS) where he led teams in EC2 Core Platform and the development of the AWS Payment Cryptography service.

Labels

.NET .NET 10 .NET 3.5 Active Directory AD DS Adoption AI AI coding AI Ethics AI Hype Alerts Amazon Cognito Amazon DLM Amazon Q Anthropic AppDomain Architecture Artificial Intelligence Asia Pacific Sydney ASP.net ASPxGridView Audit Readiness Auto Recovery Automation AWS AWS Certified AWS Lambda AWS Payment Cryptography AWS SDK AWS Security Specialty Azure Azure DevOps Server Backup BIG-IP C# Career Growth Cartes Bancaires CB Certificate Bundle Certification Claude Cloud Cloud Certification Cloud Hosting Cloud Security CloudWatch CLR Content Query Cost Optimization Credentials CyberChef Database Defense Industry Deloitte Developer Tools Developers DevEx DevExpress DevOps DISA Disk Space DISM Distributed Systems DoD DoD CC SRG DUKPT EBS EC2 Engineering Engineering Leadership Engineering Management EnPasFltV2 Enterprise Event Receiver Exam F5 Federal IT FedRAMP Fintech FISMA GAC Generative AI GitHub gMSA GovCloud Government Compliance GridView Hardware Security Modules HSM IAM Identity Management IIS Infra Infrastructure as Code IT Tools Jacob Marks JavaScript jQuery Lambda Leadership Linqpad LLM lsass.exe LTM Memory Optimization Mentorship Microsoft Migration Multi-Region Keys NACL Native AOT Network Architecture Networking NIST ODBC Open Source Payment Cryptography Payments PCI Compliance Performance Platform Platform Architecture Power Tools PowerShell Python re:Invent Reachability Analyzer Redshift Relationships List Replace Root Volume SAA-C00 SAP-C00 Security Security Group Serverless SES SharePoint SharePoint 2010 Site Reliability SMTP Snapshot Software Engineering Solutions Architect Solutions Architect Professional SP 2007 SPAWAR SSL STIG Storage Strategy Sydney SysAdmin Team Foundation Server Team Utilities Tech Industry Technical Depth Technology TFS Tools Troubleshooting Upgrade Visual Studio VPC VPC Flow Logs Web Development WebPart WinDirStat Windows Server Windows Server 2025 WinForms