Currently, my setup involves using mysql2 to establish a connection with AWS Aurora DB.
Unfortunately, I am encountering issues with connecting to the cluster and retrieving records.
connection = createConnection({
host: 'music-instance-2.cairvpszramp.us-east-1.rds.amazonaws.com',
user: 'user',
password: 'password',
database: 'music'
});
console.log("Before Connection")
const [rows, fields] = await connection.execute('USE Music;SELECT * FROM artist;');
console.log("After Connection")
return {
statusCode: 200,
body: JSON.stringify(rows)
};
An error message that keeps appearing reads:
Error Caught TypeError: (intermediate value) is not iterable at Runtime. (/var/task/index.js:27:36) at Generator.next () at fulfilled (/var/task/index.js:5:58)
I would appreciate assistance in understanding this error and finding a solution to rectify it.
Additional details:
- My codebase is implemented in TypeScript
- This script executes within an AWS Lambda function utilizing Node.js 18
console.log(data)
output:
_events: [Object: null prototype] {},_eventsCount: 0, _maxListeners: undefined, next: null, statement: undefined, sql: 'USE Music;SELECT * FROM artist;', values: undefined, onResult: undefined, parameters: undefined, insertId: 0,timeout: undefined, queryTimeout: null, _rows: [], _fields: [], _result: [], _fieldCount: 0, _rowParser: null, _executeOptions: { sql: 'USE Music;SELECT * FROM artist;', values: undefined }, _resultIndex: 0, _localStream: null, _unpipeStream: [Function (anonymous)], _streamFactory: undefined, _connection: null, [Symbol(kCapture)]: false