ballerinax/aws.redshift Ballerina library

0.1.0

Overview

The Ballerina connector for Amazon Redshift enables you to programmatically access Amazon Redshift, a fully managed data warehouse service in the cloud. This connector leverages the Java Database Connectivity (JDBC) API to provide operations for executing Data Definition Language (DDL) commands, Structured Query Language (SQL) commands, and SQL functions to interact with Amazon Redshift. For detailed information about Amazon Redshift SQL commands, refer to the official documentation.

Prerequisites

Before using this connector in your Ballerina application, ensure you have the following prerequisites:

To connect to Amazon Redshift

  • Create an Amazon Web Services (AWS) account.
  • Set up an Amazon Redshift cluster.
  • Obtain the AWS access key, secret key, and the Redshift cluster endpoint.

Quickstart

To use the Amazon Redshift connector in your Ballerina application, follow these steps:

Step 1: Import connector and driver

Import the following modules into the Ballerina project:

Copy
import ballerina/sql;
import ballerinax/aws.redshift;      // Get the AWS Redshift connector
import ballerinax/aws.redshift.driver as _;   // Get the AWS Redshift driver

Step 2: Create a new connector instance

Initialize the Redshift connector by providing the necessary connection details:

redshift:Client dbClient = check new (jdbcUrl, <username>, <password>);

Step 3: Invoke the connector operations

Following is a sample code to query data from a table.

Copy
import ballerina/io;
import ballerina/sql;
import ballerinax/aws.redshift; // Get the AWS Redshift connector
import ballerinax/aws.redshift.driver as _; // Get the AWS Redshift driver

// Connection Configurations
configurable string jdbcUrl = ?;
configurable string user = ?;
configurable string password = ?;

// Initialize the Redshift client
redshift:Client dbClient = check new (jdbcUrl, user, password);

public function main() returns error? {
   sql:ParameterizedQuery sqlQuery = `SELECT * FROM Users limit 10`;
   stream<record {}, error?> resultStream = dbClient->query(sqlQuery);
   check from record {} result in resultStream
   do {
      io:println("Full details of users: ", result);
   };
}
  1. Use bal run command to compile and run the Ballerina program.

Import

import ballerinax/aws.redshift;Copy

Metadata

Released date: 6 months ago

Version: 0.1.0

License: Apache-2.0


Compatibility

Platform: java17

Ballerina version: 2201.8.0

GraalVM compatible: Yes


Pull count

Total: 242

Current verison: 34


Weekly downloads


Source repository


Keywords

Data Warehouse

Columnar Storage

Cost/Paid

vendor/aws


Contributors

Other versions