雅典娜查询
雅典娜查询 提供简单的接口以获取雅典娜查询结果.
雅典娜 - Query的灵感和前卫 雅典纳表达式。 。 。 .
3⁄4 ̄ ̧漯B 雅典娜-查询只支持aws-sdk v3. 所以,如果你使用aws -sdk v2,我们建议使用 雅典纳表达式。 。 。 .
安装
npm install @classmethod/athena-query @aws-sdk/client-athena
yarn add @classmethod/athena-query @aws-sdk/client-athena
使用量
基本用途
雅典娜-查询提供 query() 方法为 aync 生成函数。 。 。 .
这样我们就可以用它 for await () {}, (中文(简体) ),
import { Athena } from "@aws-sdk/client-athena";
import AthenaQuery from "@classmethod/athena-query";
const athena = new Athena({});
const athenaQuery = new AthenaQuery(athena);
for await (const item of athenaQuery.query("SELECT * FROM waf_logs;")) {
console.log(item); // You can get all items across pagination.
}
如果你打破循环,雅典娜 - 查询 不呼叫不必要的页面 get-query-result api. (英语).
如果想要缩小被询问数据的大小而不是检索到的数据,可以使用 限制条款。 。 。 .
选项
初始化AthenaQuery类时,可以通过选项指定查询目标.
const athenaQuery = new AthenaQuery(athena, {
db: "test-db",
workgroup: "test-workgroup",
catalog: "test-catalog",
outputLocation: "s3://path/to/query/bucket/",
});
在向雅典娜查询时,可以通过查询选项.
const resultGen = athenaQuery.query(
`
SELECT * FROM waf_logs
WHERE name = ? AND groupId = ? AND score > ?;
`,
{
executionParameters: ["test", 123, 456n],
},
);