How to use aws athena using nodejs?

偶尔善良 提交于 2019-12-21 05:29:12

问题


  • 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

回答1:


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);
  }
});



回答2:


Just use the Athena Service on the JS SDK.

Athena JS Documentation

AWS JS SDK



来源:https://stackoverflow.com/questions/41504088/how-to-use-aws-athena-using-nodejs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!