Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes #12

Merged
merged 8 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build
on:
push:
branches:
- master
- main
- 2201.[0-9]+.x
repository_dispatch:
types: check_connector_for_breaking_changes
Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,18 @@ Now, utilize the available connector operations.
#### Read data from the database

```ballerina
// Create the result record to match the columns of the table being queried.
type User record {|
string name;
string email;
string state;
|};

sql:ParameterizedQuery sqlQuery = `SELECT * FROM Users limit 10`;
stream<record {}, error?> resultStream = dbClient->query(sqlQuery);
check from record {} result in resultStream
stream<User, error?> resultStream = dbClient->query(sqlQuery);
check from User user in resultStream
do {
io:println("Full details of users: ", result);
io:println("Full details of users: ", user);
};
```

Expand All @@ -103,6 +110,12 @@ _ = check dbClient->execute(sqlQuery);

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).

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

3. [Music store](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/blob/main/examples/music-store) - This example illustrates the process of creating an HTTP RESTful API with Ballerina to perform basic CRUD operations on a database, specifically AWS Redshift, involving setup, configuration, and running 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).
Expand Down
19 changes: 16 additions & 3 deletions ballerina/Module.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,18 @@ Now, utilize the available connector operations.
#### Read data from the database

```ballerina
// Create the result record to match the columns of the table being queried.
type User record {|
string name;
string email;
string state;
|};

sql:ParameterizedQuery sqlQuery = `SELECT * FROM Users limit 10`;
stream<record {}, error?> resultStream = dbClient->query(sqlQuery);
check from record {} result in resultStream
stream<User, error?> resultStream = dbClient->query(sqlQuery);
check from User user in resultStream
do {
io:println("Full details of users: ", result);
io:println("Full details of users: ", user);
};
```

Expand All @@ -98,3 +105,9 @@ _ = 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).

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

3. [Music store](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/blob/main/examples/music-store) - This example illustrates the process of creating an HTTP RESTful API with Ballerina to perform basic CRUD operations on a database, specifically AWS Redshift, involving setup, configuration, and running examples.
19 changes: 16 additions & 3 deletions ballerina/Package.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,18 @@ Now, utilize the available connector operations.
#### Read data from the database

```ballerina
// Create the result record to match the columns of the table being queried.
type User record {|
string name;
string email;
string state;
|};

sql:ParameterizedQuery sqlQuery = `SELECT * FROM Users limit 10`;
stream<record {}, error?> resultStream = dbClient->query(sqlQuery);
check from record {} result in resultStream
stream<User, error?> resultStream = dbClient->query(sqlQuery);
check from User user in resultStream
do {
io:println("Full details of users: ", result);
io:println("Full details of users: ", user);
};
```

Expand All @@ -99,6 +106,12 @@ _ = check dbClient->execute(sqlQuery);

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).

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

3. [Music store](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/blob/main/examples/music-store) - This example illustrates the process of creating an HTTP RESTful API with Ballerina to perform basic operations on a database, specifically AWS Redshift, involving setup, configuration, and running 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)

Expand Down
12 changes: 7 additions & 5 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ The `ballerinax/aws.redshift` connector facilitates seamless integration with Am

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

3. [Music store](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/blob/main/examples/music-store) - This example illustrates the process of creating an HTTP RESTful API with Ballerina to perform basic CRUD operations on a database, specifically AWS Redshift, involving setup, configuration, and running examples.

## 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="<JDBC URL of the created Redshift cluster>"
user="<Username>"
password="<Password>"
```
```toml
jdbcUrl="<JDBC URL of the created Redshift cluster>"
user="<Username>"
password="<Password>"
```

## Running an Example

Expand Down
2 changes: 1 addition & 1 deletion examples/music-store/music_store.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Configure AWS Redshift API credentials in `Config.toml` within the setup and mus

## Run the Example

1. First, run the [`setup`](setup) ballerina program to set up the `MUSIC_STORE` database used in the sample. Execute the following command:
1. First, run the [`setup`](https://github.com/ballerina-platform/module-ballerinax-aws.redshift/blob/main/examples/music-store/setup) ballerina program to set up the `MUSIC_STORE` database used in the sample. Execute the following command:
```bash
cd setup
bal run
Expand Down
15 changes: 11 additions & 4 deletions examples/query/query.bal
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@ configurable string password = ?;
// Initialize the Redshift client
redshift:Client dbClient = check new (jdbcUrl, user, password);

// Create the result record to match the columns of the table being queried.
type User record {|
string name;
string email;
string state;
|};

public function main() returns error? {
sql:ParameterizedQuery sqlQuery = `SELECT * FROM your_table_name limit 10`;
stream<record {}, error?> resultStream = dbClient->query(sqlQuery);
check from record {} result in resultStream
sql:ParameterizedQuery sqlQuery = `SELECT * FROM Users limit 10`;
stream<User, error?> resultStream = dbClient->query(sqlQuery);
check from User user in resultStream
do {
io:println("Full details of users: ", result);
io:println("Full details of users: ", user);
};
}
Loading