Giter Club home page Giter Club logo

athena-query's Introduction

Athena-Query

Release CI npm version GitHub license

Athena-Query provide simple interface to get athena query results.

Athena-Query was inspired and forked from athena-express.

Warning Athena-Query support aws-sdk v3 only. So if you use aws-sdk v2, we recommend to use athena-express.

Installation

npm install @classmethod/athena-query @aws-sdk/client-athena
yarn add @classmethod/athena-query @aws-sdk/client-athena

Usage

Basic Usage

Athena-Query provide query() method as async generator function. So we can use it with 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.
}

And if you break loop out, Athena-Query don't call unnecessary pages of get-query-result api.

If you want to reduce the size of the queried data rather than the retrieved data, you can use the LIMIT clause.

Options

When you initialize AthenaQuery class, you can pass options to specify the query target.

const athenaQuery = new AthenaQuery(athena, {
  db: "test-db",
  workgroup: "test-workgroup",
  catalog: "test-catalog",
});

When you query to Athena, you can pass options for query.

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

athena-query's People

Contributors

dependabot[bot] avatar diggymo avatar github-actions[bot] avatar renovate[bot] avatar yamatatsu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.