5
  • 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
Ben Swinburne
  • 25,669
  • 10
  • 69
  • 108
rajeswari
  • 279
  • 1
  • 4
  • 13
  • 1
    Welcome to SO. Please read [What topics can I ask about](http://stackoverflow.com/help/on-topic) and [How to ask a good question](http://stackoverflow.com/help/how-to-ask) And [the perfect question](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) And how to create a [Minimal, Complete and Verifiable example](http://stackoverflow.com/help/mcve) SO is **not a Tutorial or Library Finding service** – RiggsFolly Jan 06 '17 at 10:56
  • I cant speak for NodeJS but in Python there is a module called Pyhive, and for a generic JDBC connection you have to use the Hive JDBC driver which is available from AWS, and requires some configuration. – Henry Jan 06 '17 at 14:43

4 Answers4

4

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);
  }
});
Flair
  • 169
  • 1
  • 5
3

Just use the Athena Service on the JS SDK.

Athena JS Documentation

AWS JS SDK

Sua Morales
  • 894
  • 10
  • 21
1

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

mailtobash
  • 2,310
  • 3
  • 15
  • 17
0

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

cigien
  • 57,834
  • 11
  • 73
  • 112
SWIK
  • 714
  • 7
  • 12
  • When linking to your own site or content (or content that you are affiliated with), you [must disclose your affiliation _in the answer_](/help/promotion) in order for it not to be considered spam. Having the same text in your username as the URL or mentioning it in your profile is not considered sufficient disclosure under Stack Exchange policy. Please add a disclosure to *all* your answers where you've linked to your own youtube videos. – cigien Jul 24 '22 at 18:57
  • Is there any sample disclosure format? Little bit confused about it. – SWIK Jul 26 '22 at 11:20
  • The disclosure doesn't need to be particularly formal. You just need to make it very clear in the answer itself that you're affiliated with the linked content. I've edited this answer to demonstrate how that can be done. Hope that clears it up. – cigien Jul 26 '22 at 12:44
  • Ok. Got it now. Thanks for help here. – SWIK Jul 26 '22 at 13:37