Ranieri Mazili
Ranieri Mazili

Reputation: 833

What to use to connect on AWS Aurora Serverless V2 using NodeJS?

On the official @aws-sdk/client-rds-data documentation, it says:

Amazon RDS provides an HTTP endpoint to run SQL statements on an Amazon Aurora Serverless v1 DB cluster. To run these statements, you work with the Data Service API.

The Data Service API isn't supported on Amazon Aurora Serverless v2 DB clusters.

But it does't point to another library to connect on a Serverless v2. Is it impossible with NodeJS?

Really appreciate any help

Upvotes: 1

Views: 1153

Answers (1)

Sergio N
Sergio N

Reputation: 316

I'm using simple driver to connect AWS Aurora MySQL Serverless V2 directly, code below.

https://www.npmjs.com/package/mysql

const mysql = require('mysql')
dbconn  = mysql.createConnection({
                                  host: host,
                                  user: user,
                                  password: password,
                                  database: database,
                                  multipleStatements: true,
                                  connectionLimit: 10
                })
                
dbconn.query(sql, (err,result)=>{
                            if(err) {
                                console.log(err)
                                i_errors++;
                            } 
                            console.log(result);
                            
                           
                    }
                );
                
dbconn.end();

Upvotes: 1

Related Questions