ballerinax/aws.redshift Ballerina library

1.0.0

Overview

Amazon Redshift is a powerful and fully-managed data warehouse service provided by Amazon Web Services (AWS), designed to efficiently analyze large datasets with high performance and scalability.

The ballerinax/aws.redshift connector facilitates seamless integration with Amazon Redshift, offering Ballerina users a convenient and expressive way to connect, query, and interact with Redshift clusters.

Set up guide

To effectively utilize the Ballerina AWS Redshift connector, you must have an Amazon Redshift cluster. Follow these steps to create an AWS Redshift cluster.

Step 1: Login to AWS Console

  1. Begin by logging into the AWS Management Console.

Step 2: Navigate to Amazon Redshift and Create a Cluster

  1. In the AWS Console, navigate to the Amazon Redshift service. Click on the "Create cluster" button to initiate the process of creating a new Amazon Redshift cluster.

    Create cluster

    Create cluster

Step 3: Configure Cluster Settings

  1. Follow the on-screen instructions to configure your Redshift cluster settings, including cluster identifier, database name, credentials, and other relevant parameters.

    Basic configs

  2. Configure security groups to control inbound and outbound traffic to your Redshift cluster. Ensure that your Ballerina application will have the necessary permissions to access the cluster.

    Security configs

  3. Record the username and password you set during the cluster configuration. These credentials will be used to authenticate your Ballerina application with the Redshift cluster.

    Credentials

  4. Finally, review your configuration settings, and once satisfied, click "Create cluster" to launch your Amazon Redshift cluster.

Step 4: Wait for Cluster Availability

  1. It may take some time for your Redshift cluster to be available. Monitor the cluster status in the AWS Console until it shows as "Available".

    Availability

  2. After the cluster is successfully created, copy the JDBC URL. You can find this information in the cluster details or configuration section of the AWS Console.

    JDBC URL

Quickstart

To use the aws.redshift connector in your Ballerina application, modify the .bal file as follows:

Step 1: Import the connector

Import the ballerinax/aws.redshift package and the ballerinax/aws.redshift.driver into your Ballerina project.

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

Step 2: Instantiate a new client

Create a redshift:Client with the values obtained in the previous steps.

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

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

Step 3: Invoke the connector operation

Now, utilize the available connector operations.

Read data from the database

Copy
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);
   };

Insert data into the database

Copy
sql:ParameterizedQuery sqlQuery = `INSERT INTO your_table_name (firstname, lastname, state, email, username)
   VALUES ('Cody', 'Moss', 'ON', 'dolor.nonummy@ipsumdolorsit.ca', 'WWZ18EOX');`;
_ = check dbClient->execute(sqlQuery);

Examples

The aws.redshift connector provides practical examples illustrating usage in various scenarios. Explore these examples.

Import

import ballerinax/aws.redshift;Copy

Metadata

Released date: about 1 month ago

Version: 1.0.0

License: Apache-2.0


Compatibility

Platform: java17

Ballerina version: 2201.8.0

GraalVM compatible: Yes


Pull count

Total: 

Current verison: 3


Weekly downloads


Source repository


Keywords

Data Warehouse
Columnar Storage
Cost/Paid
vendor/aws

Contributors

Other versions