简体   繁体   中英

How can I connect to my redshift cluster using Node.js?

I am trying to connect to one of my Redshift clusters so that I can fetch data from one of the tables there. I am using Node.js for it.

I used the createCluster() method and created a cluster, but I cannot seem to find a method to read from/connect to it. The aws docs are rather confusing for me as I am new to the aws environment.

How can I connect to an existing cluster and get some data out of a table in it?

Thanks:)

npm i node-redshift

you can connect using this npm name node-redshift https://www.npmjs.com/package/node-redshift

OR

regarding the AWS, i think this will help you

Trying to Connect to Redshift Over AWS Lambda

I was trying to make the 'node-redshift' module work before I asked this question here. I found out what I was missing out on. I had to have a security group associated with my cluster. There was no option to create a security group in my region (Asia Pacific - Mumbai). I changed the region and was able to create the group, set the appropriate port and IP and it worked.

To those who are using node-redshift, it was working fine with 12.13.1 but was not responding for 14.15.0 LTS.

Maybe you may want to check your Node version once.

I was able to connect AWS-Lambda to Redshift importing 'node-redshift' module into the Lambda Function. The most important thing while creating lambda layer try to make the layer for 'node-redshift' package for version nodejs10.x. I tried adding the layer for nodejs14.x and was struggling to make a connection to Redshift which was not happening. So after changing the version from nodejs14.x to nodejs10.x it worked. Moreover thanks to Vijender R , his answer also gave me the direction to change the versioning for working with the 'node-redshift' package.

Had the same issue, the reason - I've updated node.js. After returned it to version 11.1.0, everything works ok.

The solution is to find something instead node-redshift (since it was updated 4 years ago)

It may be worth trying to use https://www.npmjs.com/package/@aws-sdk/client-redshift-data , which seems to be maintained by AWS itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM