Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use aws athena using nodejs?

  • 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
like image 826
rajeswari Avatar asked Jan 06 '17 10:01

rajeswari


3 Answers

I am using athena like following way in my nodejs project :

download JDBC driver from AWS. Create a connector.js file. npm install jdbc NPM. Paste followings:

var JDBC = require('jdbc');
var jinst = require('jdbc/lib/jinst');
 
if (!jinst.isJvmCreated()) {
  jinst.addOption("-Xrs");
  jinst.setupClasspath(['./AthenaJDBC41-*.jar']);
}
 
var config = {
  // Required 
  url: 'jdbc:awsathena://athena.*.amazonaws.com:443',
   // Optional 
  drivername: 'com.amazonaws.athena.jdbc.AthenaDriver',
  minpoolsize: 10,
  maxpoolsize: 100,
  properties: {
                s3_staging_dir: 's3://aws-athena-query-results-*/',
                log_path: '/logs/athenajdbc.log',
                user: 'access_key',
                password: 'secret_key'
   }
};
 
 
var hsqldb = new JDBC(config);
 
hsqldb.initialize(function(err) {
  if (err) {
    console.log(err);
  }
});
like image 193
Flair Avatar answered Oct 06 '22 16:10

Flair


Just use the Athena Service on the JS SDK.

Athena JS Documentation

AWS JS SDK

like image 3
Sua Morales Avatar answered Oct 06 '22 16:10

Sua Morales


You could use the athena-express module from here, as documented by AWS here

like image 1
mailtobash Avatar answered Oct 06 '22 15:10

mailtobash