- Athena 是一种分析服务,用于使用 sql 查询从 s3 检索数据。
- 我已经使用 t aws 控制台查询了 s3 中的数据
- 需要使用 nodejs 代码访问 aws athena
最佳答案
我在我的 nodejs 项目中使用 athena,就像下面这样:
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);
}
});
关于mysql - 如何使用 aws athena 使用 nodejs?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41504088/