- Athena is analytics service for retrieving data from s3 using sql query.
- I have queried data in s3 using t aws console
- Need access to aws athena using nodejs code
How to use aws athena using nodejs?
10.1k views Asked by rajeswari At
5
There are 5 answers
4
On
You need to use aws-sdk and athena-express dependencies,
There's a full working tutorial in this video I made: https://www.youtube.com/watch?v=aBf5Qo9GZ1Yac
0
On
This is code about node js with Athena connection....
const AthenaExpress = require("athena-express");
const aws = require("aws-sdk");
const awsCredentials = {
region: "us-east-1",
accessKeyId: "xxxxx", // Modified key name
secretAccessKey: "xxxxxxxxx", // Modified key name
};
aws.config.update(awsCredentials);
const athenaExpressConfig = {
aws: aws,
s3: "s3://xyz/abc/",
getStats: true,
};
const athenaExpress = new AthenaExpress(athenaExpressConfig);
(async () => {
let myQuery = {
sql: "SELECT id, name, address FROM dummydata1ealogs LIMIT 3",
db: "database",
};
try {
let results = await athenaExpress.query(myQuery);
console.log(results);
} catch (error) {
console.log(error);
}`enter code here`
})();
I am using athena like following way in my nodejs project :