# @classmethod/athena-query 中文文档

规范地址：https://npmcn.com/package/%40classmethod/athena-query/

版本：1\.4\.0
npm 元数据更新时间：2024-03-31T15:51:50.796Z
中文译文更新时间：2026-11-09T23:52:22.079Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40classmethod/athena-query
原文对照：https://npmcn.com/package/%40classmethod/athena-query/?lang=original
项目主页：https://github.com/classmethod/athena-query#readme
源码仓库：https://github.com/classmethod/athena-query

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：19.8 kB，8 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：@aws-sdk/client-athena ^3\.x\.x
- 首次发布：2022-11-30T03:14:40.138Z
- 最新版本发布：2024-03-31T15:51:50.588Z
- 近 30 天下载量：10049（2026-10-10 至 2026-11-08，npm 官方下载统计）
- 已发布版本数：18（近 12 个月 0 个）

## 中文简介

Athena-Query 通过在 AWS SDK 中整合并抽象出几种方法, 使得在 Amazon Athena 上执行 SQL 查询更容易

## 安装

```sh
npm install @classmethod/athena-query
```

也可以使用：`pnpm add @classmethod/athena-query`、`yarn add @classmethod/athena-query`、`bun add @classmethod/athena-query`

## README

# 雅典娜查询

![Release](https://github.com/classmethod/athena-query/workflows/release/badge.svg) ![CI](https://github.com/classmethod/athena-query/workflows/CI/badge.svg) [![npm version](https://img.shields.io/npm/v/@classmethod/athena-query.svg)](https://www.npmjs.com/@classmethod/athena-query) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/classmethod/athena-query/blob/main/LICENSE)

**雅典娜查询** 提供简单的接口以获取雅典娜查询结果.

雅典娜 - Query的灵感和前卫 [雅典纳表达式](https://github.com/ghdna/athena-express#readme)。 。 。 .

> **3⁄4 ̄ ̧漯B** 雅典娜-查询只支持aws-sdk v3. 所以,如果你使用aws -sdk v2,我们建议使用 [雅典纳表达式](https://github.com/ghdna/athena-express#readme)。 。 。 .

## 安装

```
npm install @classmethod/athena-query @aws-sdk/client-athena
```

```
yarn add @classmethod/athena-query @aws-sdk/client-athena
```

## 使用量

### 基本用途

雅典娜-查询提供 `query()` 方法为 [aync 生成函数](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function*)。 。 。 . 这样我们就可以用它 `for await () {}`, (中文(简体) ),

```ts
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. (英语).

如果想要缩小被询问数据的大小而不是检索到的数据,可以使用 [限制条款](https://docs.aws.amazon.com/athena/latest/ug/select.html#select-parameters)。 。 。 .

### 选项

初始化AthenaQuery类时,可以通过选项指定查询目标.

```ts
const athenaQuery = new AthenaQuery(athena, {
  db: "test-db",
  workgroup: "test-workgroup",
  catalog: "test-catalog",
  outputLocation: "s3://path/to/query/bucket/",
});
```

在向雅典娜查询时,可以通过查询选项.

```ts
const resultGen = athenaQuery.query(
  `
    SELECT * FROM waf_logs
    WHERE name = ? AND groupId = ? AND score > ?;
  `,
  {
    executionParameters: ["test", 123, 456n],
  },
);
```

## 常见问题

### @classmethod/athena-query 是什么？

Athena-Query 通过在 AWS SDK 中整合并抽象出几种方法, 使得在 Amazon Athena 上执行 SQL 查询更容易

### 如何安装 @classmethod/athena-query？

在项目目录运行 npm install @classmethod/athena-query，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：@aws-sdk/client-athena（^3\.x\.x）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @classmethod/athena-query 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @classmethod/athena-query 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @classmethod/athena-query 可以商用吗？

@classmethod/athena-query 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @classmethod/athena-query 的下载量有多少？

根据 npm 官方下载统计，@classmethod/athena-query 在 2026/10/10 – 2026/11/08 这 30 天内被下载 10,049 次，日均约 335 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @classmethod/athena-query 还在维护吗？

最新版本 1\.4\.0 发布于 2024/03/31（2 年前）；至今共发布 18 个版本，其中过去 12 个月发布了 0 个；首次发布于 2022/11/30。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

