如何通过Node.js使用AWS Athena? [英] How to use aws athena using nodejs?
本文介绍了如何通过Node.js使用AWS Athena?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
- Athena是一种分析服务,用于使用sql查询从s3检索数据.
- 我已经使用taws控制台在s3中查询了数据</li>
- 需要使用nodejs代码访问AWS Athena
- 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
推荐答案
我在nodejs项目中使用雅典娜的方式如下:
I am using athena like following way in my nodejs project :
从 AWS 下载JDBC驱动程序. 创建一个connector.js文件. npm install jdbc NPM . 粘贴以下内容:
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);
}
});
这篇关于如何通过Node.js使用AWS Athena?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文