diff --git a/.github/workflows/build-with-bal-test-graalvm.yml b/.github/workflows/build-with-bal-test-graalvm.yml new file mode 100644 index 0000000..a319c46 --- /dev/null +++ b/.github/workflows/build-with-bal-test-graalvm.yml @@ -0,0 +1,17 @@ +name: GraalVM Check + +on: + schedule: + - cron: "30 18 * * *" + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + +jobs: + call_stdlib_workflow: + name: Run StdLib Workflow + if: ${{ github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository_owner == 'ballerina-platform') }} + uses: ballerina-platform/ballerina-standard-library/.github/workflows/build-with-bal-test-graalvm-connector-template.yml@main + secrets: inherit diff --git a/README.md b/README.md index c5fd981..e1c8bb2 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,180 @@ Ballerina AWS Redshift Connector =================== -[![Build](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/workflows/CI/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/actions?query=workflow%3ACI) +[![Build](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/actions/workflows/ci.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/actions/workflows/ci.yml) [![Trivy](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/actions/workflows/trivy-scan.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/actions/workflows/trivy-scan.yml) [![codecov](https://codecov.io/gh/ballerina-platform/module-ballerinax-aws.redshift/branch/main/graph/badge.svg)](https://codecov.io/gh/ballerina-platform/module-ballerinax-aws.redshift) [![GitHub Last Commit](https://img.shields.io/github/last-commit/ballerina-platform/module-ballerinax-aws.redshift.svg)](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/commits/main) -[![GraalVM Check](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/actions/workflows/build-with-bal-test-native.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/actions/workflows/build-with-bal-test-native.yml) +[![GraalVM Check](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/actions/workflows/build-with-bal-test-graalvm.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/actions/workflows/build-with-bal-test-graalvm.yml) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -The AWS Redshift connector for [Ballerina](https://ballerina.io/) facilitates seamless interaction with Amazon Redshift data warehouses, enabling programmatic access to various applications, databases, APIs, and services through the Java Database Connectivity (JDBC) API using Ballerina. This connector empowers users to execute diverse set of standard Data Definition Language (DDL) commands, SQL commands, and SQL functions for efficient querying of data sources within the Amazon Redshift environment. +[Amazon Redshift](https://aws.amazon.com/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. -For more information, go to the module(s). -- [aws.redshift](Module.md) +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, utilizing the AWS Redshift JDBC driver available through [`ballerinax/aws.redshift.driver`](https://central.ballerina.io/ballerinax/aws.redshift.driver/latest). -## Building from the source +## Set up guide -### Setting up the prerequisites +To effectively utilize the Ballerina AWS Redshift connector, you must have an Amazon Redshift cluster. Follow these steps to create an AWS Redshift cluster. -1. Download and install Java SE Development Kit (JDK) version 17. You can install either [OpenJDK](https://adoptopenjdk.net/) or [Oracle](https://www.oracle.com/java/technologies/downloads/). +### Step 1: Login to AWS Console +1. Begin by logging into the [AWS Management Console](https://aws.amazon.com/). - > **Note:** Set the JAVA_HOME environment variable to the path name of the directory into which you installed JDK. +### 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. + +```ballerina +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. + +```ballerina +// 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 + +```ballerina +sql:ParameterizedQuery sqlQuery = `SELECT * FROM Users limit 10`; +stream resultStream = dbClient->query(sqlQuery); +check from record {} result in resultStream + do { + io:println("Full details of users: ", result); + }; +``` + +#### Insert data into the database +```ballerina +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](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/tree/master/examples). + +## Issues and projects + +The **Issues** and **Projects** tabs are disabled for this repository as this is part of the Ballerina library. To report bugs, request new features, start new discussions, view project boards, etc., visit the Ballerina library [parent repository](https://github.com/ballerina-platform/ballerina-library). + +This repository only contains the source code for the package. + +## Build from the source + +### Prerequisites + +1. Download and install Java SE Development Kit (JDK) version 17. You can download it from either of the following sources: + + * [Oracle JDK](https://www.oracle.com/java/technologies/downloads/) + * [OpenJDK](https://adoptium.net/) + + > **Note:** After installation, remember to set the `JAVA_HOME` environment variable to the directory where JDK was installed. 2. Download and install [Ballerina Swan Lake](https://ballerina.io/). -### Building the source +3. Download and install [Docker](https://www.docker.com/get-started). + + > **Note**: Ensure that the Docker daemon is running before executing any tests. + +### Build options Execute the commands below to build from the source. -- To build the library: - ```shell - ./gradlew clean build - ``` -- To run the integration tests: - ```shell - ./gradlew clean test +1. To build the package: + + ```bash + ./gradlew clean build + ``` + +2. To run the tests: + + ```bash + ./gradlew clean test + ``` + +3. To build the without the tests: + + ```bash + ./gradlew clean build -x test + ``` + +4. To debug package with a remote debugger: + + ```bash + ./gradlew clean build -Pdebug= + ``` + +5. To debug with the Ballerina language: + + ```bash + ./gradlew clean build -PbalJavaDebug= + ``` + +6. Publish the generated artifacts to the local Ballerina Central repository: + + ```bash + ./gradlew clean build -PpublishToLocalCentral=true ``` -## Contributing to Ballerina +7. Publish the generated artifacts to the Ballerina Central repository: + + ```bash + ./gradlew clean build -PpublishToCentral=true + ``` + +## Contribute to Ballerina -As an open source project, Ballerina welcomes contributions from the community. +As an open-source project, Ballerina welcomes contributions from the community. For more information, go to the [contribution guidelines](https://github.com/ballerina-platform/ballerina-lang/blob/master/CONTRIBUTING.md). @@ -48,6 +184,7 @@ All the contributors are encouraged to read the [Ballerina Code of Conduct](http ## Useful links -* Discuss the code changes of the Ballerina project in [ballerina-dev@googlegroups.com](mailto:ballerina-dev@googlegroups.com). +* For more information go to the [`aws.redshift` package](https://lib.ballerina.io/ballerinax/aws.redshift/latest). +* For example demonstrations of the usage, go to [Ballerina By Examples](https://ballerina.io/learn/by-example/). * Chat live with us via our [Discord server](https://discord.gg/ballerinalang). * Post all technical questions on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag. diff --git a/ballerina/Module.md b/ballerina/Module.md index 70b7e87..61740bc 100644 --- a/ballerina/Module.md +++ b/ballerina/Module.md @@ -1,59 +1,100 @@ ## Overview -The [Ballerina](https://ballerina.io/) 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. +[Amazon Redshift](https://aws.amazon.com/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. -## Prerequisites -Before using this connector in your Ballerina application, ensure you have the following prerequisites: +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. -### To connect to Amazon Redshift +## Set up guide -* 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. +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](https://aws.amazon.com/). + +### 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](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-aws.redshift/master/docs/setup/resources/create-cluster-1.png) + + ![Create cluster](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-aws.redshift/master/docs/setup/resources/create-cluster-2.png) + +### 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](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-aws.redshift/master/docs/setup/resources/basic-configs.png) + +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](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-aws.redshift/master/docs/setup/resources/security-configs.png) + +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](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-aws.redshift/master/docs/setup/resources/credentials.png) + +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](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-aws.redshift/master/docs/setup/resources/availability.png) + +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](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-aws.redshift/master/docs/setup/resources/jdbc-url.png) ## Quickstart -To use the Amazon Redshift connector in your Ballerina application, follow these steps: +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. -### Step 1: Import connector and driver -Import the following modules into the Ballerina project: ```ballerina -import ballerina/sql; -import ballerinax/aws.redshift; // Get the AWS Redshift connector -import ballerinax/aws.redshift.driver as _; // Get the AWS Redshift driver +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, , ); +### Step 2: Instantiate a new client + +Create a `redshift:Client` with the values obtained in the previous steps. + +```ballerina +// 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 operations +### Step 3: Invoke the connector operation -Following is a sample code to query data from a table. +Now, utilize the available connector operations. + +#### Read data from the database + +```ballerina +sql:ParameterizedQuery sqlQuery = `SELECT * FROM Users limit 10`; +stream resultStream = dbClient->query(sqlQuery); +check from record {} result in resultStream + do { + io:println("Full details of users: ", result); + }; +``` + +#### Insert data into the database ```ballerina - 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 resultStream = dbClient->query(sqlQuery); - check from record {} result in resultStream - do { - io:println("Full details of users: ", result); - }; - } - ``` - -2. Use `bal run` command to compile and run the Ballerina program. +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](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/tree/master/examples). diff --git a/ballerina/Package.md b/ballerina/Package.md index 39a6322..6fab16d 100644 --- a/ballerina/Package.md +++ b/ballerina/Package.md @@ -1,12 +1,103 @@ -Connects to [AWS Redshift](https://aws.amazon.com/redshift/) from Ballerina - ## Package overview -The `ballerinax/aws.redshift` is the [Ballerina](https://ballerina.io/) connector for Amazon Redshift. The AWS Redshift connector for [Ballerina](https://ballerina.io/) facilitates seamless interaction with Amazon Redshift data warehouses, enabling programmatic access to various applications, databases, APIs, and services through the Java Database Connectivity (JDBC) API using Ballerina. This connector empowers users to execute diverse set of standard Data Definition Language (DDL) commands, SQL commands, and SQL functions for efficient querying of data sources within the Amazon Redshift environment. -### Compatibility -| | Version | -|-----------------------------------|---------------------------------| -| Ballerina Language | Ballerina Swan Lake 2201.8.0 | +[Amazon Redshift](https://aws.amazon.com/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](https://aws.amazon.com/). + +### 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](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-aws.redshift/master/docs/setup/resources/create-cluster-1.png) + + ![Create cluster](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-aws.redshift/master/docs/setup/resources/create-cluster-2.png) + +### 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](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-aws.redshift/master/docs/setup/resources/basic-configs.png) + +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](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-aws.redshift/master/docs/setup/resources/security-configs.png) + +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](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-aws.redshift/master/docs/setup/resources/credentials.png) + +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](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-aws.redshift/master/docs/setup/resources/availability.png) + +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](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-aws.redshift/master/docs/setup/resources/jdbc-url.png) + +## 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. + +```ballerina +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. + +```ballerina +// 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 + +```ballerina +sql:ParameterizedQuery sqlQuery = `SELECT * FROM Users limit 10`; +stream resultStream = dbClient->query(sqlQuery); +check from record {} result in resultStream + do { + io:println("Full details of users: ", result); + }; +``` + +#### Insert data into the database +```ballerina +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](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/tree/master/examples). ## Report issues To report bugs, request new features, start new discussions, view project boards, etc., go to the [Ballerina Extended Library repository](https://github.com/ballerina-platform/ballerina-library) diff --git a/docs/setup/resources/availability.png b/docs/setup/resources/availability.png new file mode 100644 index 0000000..13699e2 Binary files /dev/null and b/docs/setup/resources/availability.png differ diff --git a/docs/setup/resources/basic-configs.png b/docs/setup/resources/basic-configs.png new file mode 100644 index 0000000..6779e03 Binary files /dev/null and b/docs/setup/resources/basic-configs.png differ diff --git a/docs/setup/resources/create-cluster-1.png b/docs/setup/resources/create-cluster-1.png new file mode 100644 index 0000000..1137a76 Binary files /dev/null and b/docs/setup/resources/create-cluster-1.png differ diff --git a/docs/setup/resources/create-cluster-2.png b/docs/setup/resources/create-cluster-2.png new file mode 100644 index 0000000..35c6432 Binary files /dev/null and b/docs/setup/resources/create-cluster-2.png differ diff --git a/docs/setup/resources/credentials.png b/docs/setup/resources/credentials.png new file mode 100644 index 0000000..8548257 Binary files /dev/null and b/docs/setup/resources/credentials.png differ diff --git a/docs/setup/resources/jdbc-url.png b/docs/setup/resources/jdbc-url.png new file mode 100644 index 0000000..11f504c Binary files /dev/null and b/docs/setup/resources/jdbc-url.png differ diff --git a/docs/setup/resources/security-configs.png b/docs/setup/resources/security-configs.png new file mode 100644 index 0000000..615b652 Binary files /dev/null and b/docs/setup/resources/security-configs.png differ diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..9b00b3d --- /dev/null +++ b/examples/README.md @@ -0,0 +1,34 @@ +# Examples + +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. + +1. [Read data from the database](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/blob/main/examples/query) - Connects to AWS Redshift using the Redshift connector and performs a simple SQL query to select all records from a specified table with a limit of 10. + +2. [Insert data in to the database](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/blob/main/examples/execute) - Connects to AWS Redshift using the Redshift connector and performs an INSERT operation into a specified table + +## Prerequisites + +1. Follow the [instructions](https://github.com/ballerina-platform/module-ballerinax-aws.redshift#set-up-guide) to set up the AWS Redshift cluster. + +2. For each example, create a new Ballerina project. Copy the provided example code into the project, and include a `config.toml` file with the necessary JDBC URL, username, and password. Below is an example illustrating how your `config.toml` file should be structured: +```toml + jdbcUrl="" + user="" + password="" +``` + +## Running an Example + +Execute the following commands to build an example from the source: + +* To build an example: + + ```bash + bal build + ``` + +* To run an example: + + ```bash + bal run + ``` diff --git a/examples/execute/.github/README.md b/examples/execute/.github/README.md new file mode 120000 index 0000000..894d31e --- /dev/null +++ b/examples/execute/.github/README.md @@ -0,0 +1 @@ +../execute.md \ No newline at end of file diff --git a/examples/execute/Ballerina.toml b/examples/execute/Ballerina.toml new file mode 100644 index 0000000..e1a6f69 --- /dev/null +++ b/examples/execute/Ballerina.toml @@ -0,0 +1,8 @@ +[package] +org = "sample" +name = "execute" +version = "0.1.0" +distribution = "2201.8.2" + +[build-options] +observabilityIncluded = true diff --git a/examples/execute.bal b/examples/execute/execute.bal similarity index 100% rename from examples/execute.bal rename to examples/execute/execute.bal diff --git a/examples/execute/execute.md b/examples/execute/execute.md new file mode 100644 index 0000000..a9e2c44 --- /dev/null +++ b/examples/execute/execute.md @@ -0,0 +1,28 @@ +# Execute function + +Connects to AWS Redshift using the Redshift connector and performs an INSERT operation into a specified table. + +## Prerequisites + +### 1. Set up + +Refer to the set up guide in [ReadMe](../../../README.md) for necessary credentials. + +### 2. Configuration + +Configure AWS Redshift API credent ials in Config.toml in the example directory: + +```toml + jdbcUrl="" + user="" + password="" +``` + + +## Run the Example + +Execute the following command to run the example: + +```bash +bal run +``` diff --git a/examples/query/.github/README.md b/examples/query/.github/README.md new file mode 120000 index 0000000..48fad16 --- /dev/null +++ b/examples/query/.github/README.md @@ -0,0 +1 @@ +../query.md \ No newline at end of file diff --git a/examples/query/Ballerina.toml b/examples/query/Ballerina.toml new file mode 100644 index 0000000..85a39d9 --- /dev/null +++ b/examples/query/Ballerina.toml @@ -0,0 +1,8 @@ +[package] +org = "sample" +name = "query" +version = "0.1.0" +distribution = "2201.8.2" + +[build-options] +observabilityIncluded = true diff --git a/examples/query.bal b/examples/query/query.bal similarity index 94% rename from examples/query.bal rename to examples/query/query.bal index 0e7b8be..a0a267e 100644 --- a/examples/query.bal +++ b/examples/query/query.bal @@ -28,7 +28,7 @@ configurable string password = ?; redshift:Client dbClient = check new (jdbcUrl, user, password); public function main() returns error? { - sql:ParameterizedQuery sqlQuery = `SELECT * FROM Users limit 10`; + sql:ParameterizedQuery sqlQuery = `SELECT * FROM your_table_name limit 10`; stream resultStream = dbClient->query(sqlQuery); check from record {} result in resultStream do { diff --git a/examples/query/query.md b/examples/query/query.md new file mode 100644 index 0000000..263fc6d --- /dev/null +++ b/examples/query/query.md @@ -0,0 +1,28 @@ +# Query function + +Connects to AWS Redshift using the Redshift connector and performs a simple SQL query to select all records from a specified table with a limit of 10. + +## Prerequisites + +### 1. Set up + +Refer to the set up guide in [ReadMe](../../../README.md) for necessary credentials. + +### 2. Configuration + +Configure AWS Redshift API credentials in Config.toml in the example directory: + +```toml + jdbcUrl="" + user="" + password="" +``` + + +## Run the Example + +Execute the following command to run the example: + +```bash +bal run +```