All Projects → KoteiIto → Node Athena

KoteiIto / Node Athena

Licence: mit
a nodejs simple aws athena client

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Node Athena

Apex
Old apex/apex
Stars: ✭ 20 (-79.38%)
Mutual labels:  aws, aws-lambda, lambda
Lambda Monitoring
Logging and metrics libraries for AWS Lambda
Stars: ✭ 85 (-12.37%)
Mutual labels:  aws, aws-lambda, lambda
Up
Up focuses on deploying "vanilla" HTTP servers so there's nothing new to learn, just develop with your favorite existing frameworks such as Express, Koa, Django, Golang net/http or others.
Stars: ✭ 8,439 (+8600%)
Mutual labels:  aws, aws-lambda, lambda
Python Lambdarest
Flask like web framework for AWS Lambda
Stars: ✭ 84 (-13.4%)
Mutual labels:  aws, aws-lambda, lambda
Content Lambda Boto3
Automating AWS with Lambda, Python, and Boto3
Stars: ✭ 91 (-6.19%)
Mutual labels:  aws, aws-lambda, lambda
Chalice
Python Serverless Microframework for AWS
Stars: ✭ 8,513 (+8676.29%)
Mutual labels:  aws, aws-lambda, lambda
Aws Serverless Airline Booking
Airline Booking is a sample web application that provides Flight Search, Flight Payment, Flight Booking and Loyalty points including end-to-end testing, GraphQL and CI/CD. This web application was the theme of Build on Serverless Season 2 on AWS Twitch running from April 24th until end of August in 2019.
Stars: ✭ 1,290 (+1229.9%)
Mutual labels:  aws, aws-lambda, lambda
Aws Lambda Workshop
Some incremental examples suitable to host an AWS Lambda Functions workshop
Stars: ✭ 18 (-81.44%)
Mutual labels:  aws, aws-lambda, lambda
Lambda Refarch Webapp
The Web Application reference architecture is a general-purpose, event-driven, web application back-end that uses AWS Lambda, Amazon API Gateway for its business logic. It also uses Amazon DynamoDB as its database and Amazon Cognito for user management. All static content is hosted using AWS Amplify Console.
Stars: ✭ 1,208 (+1145.36%)
Mutual labels:  aws, aws-lambda, lambda
Serverless Node Simple Messaging
Simple email AWS lambda function
Stars: ✭ 75 (-22.68%)
Mutual labels:  aws, aws-lambda, lambda
Serverless Plugin Stackstorm
Plugin for serverless framework to run ready to use actions from StackStorm Exchange as AWS Lambda.
Stars: ✭ 28 (-71.13%)
Mutual labels:  aws, aws-lambda, lambda
Lambroll
lambroll is a minimal deployment tool for AWS Lambda.
Stars: ✭ 97 (+0%)
Mutual labels:  aws, aws-lambda, lambda
Lamb
monitoring tool for better visibility when developing AWS Lambda functions
Stars: ✭ 11 (-88.66%)
Mutual labels:  aws, aws-lambda, lambda
Serverless Es Logs
A Serverless plugin to transport logs to ElasticSearch
Stars: ✭ 51 (-47.42%)
Mutual labels:  aws, aws-lambda, lambda
Lambda Deployment Example
Automated Lambda Deployments with Terraform & CodePipeline
Stars: ✭ 25 (-74.23%)
Mutual labels:  aws, aws-lambda, lambda
Vapor Aws Lambda Runtime
Run your Vapor api server on AWS Lambda using the official Swift Server runtime.
Stars: ✭ 65 (-32.99%)
Mutual labels:  aws, aws-lambda, lambda
Aws Lambda Resize Images
AWS Lambda function to generate a set of resized images (large, medium, small)
Stars: ✭ 6 (-93.81%)
Mutual labels:  aws, aws-lambda, lambda
Lambdalogs
A CLI tool to trace AWS Lambda calls over multiple CloudWatch log groups.
Stars: ✭ 18 (-81.44%)
Mutual labels:  aws, aws-lambda, lambda
Serverless Node Simple Image Resize
Simple image resize AWS lambda function
Stars: ✭ 74 (-23.71%)
Mutual labels:  aws, aws-lambda, lambda
Torchlambda
Lightweight tool to deploy PyTorch models to AWS Lambda
Stars: ✭ 83 (-14.43%)
Mutual labels:  aws, aws-lambda, lambda

Build Status Coverage Status

athena-client - a simple aws athena client for nodejs and typescript

This is version 2.x document. 1.x document is here

Install with:

npm install athena-client

Usage Example

Create Client

var clientConfig = {
    bucketUri: 's3://xxxx'
}

var awsConfig = {
    region: 'xxxx', 
}
 
var athena = require("athena-client")
var client = athena.createClient(clientConfig, awsConfig)

Receive result by Callback

client.execute('SELECT 1', function(err, data) {
    if (err) {
        return console.error(err)
    }
    console.log(data)
})

Receive result by Promise

client.execute('SELECT 1').toPromise()
.then(function(data) {
    console.log(data)
})
.catch(function(err) {
    console.error(err)
})

Receive result by Stream

var stream = client.execute('SELECT 1').toStream()
stream.on('data', function(record) {
  console.log(record)
})
stream.on('query_end', function(queryExecution) {
  console.log(queryExecution)
})
stream.on('end', function() {
  console.log('end')
})
stream.on('error', function(e) {
  console.error(e)
})

API

athena = require("athena-client")

This module exposes the createClient and setConcurrentExecMax method, which execute query to AWS Athena.

client = athena.createClient([clientConfig], [awsConfig])

Returns a client instance attached to the account specified by the given clientConfig and awsConfig.

athena.setConcurrentExecMax([concurrentExecMax])

Set the number of cuncurrent execution of query max. It should be set smaller than AWS Service limit (default is 5).

clientConfig object properties

Property Default Description
bucketUri Required URI of S3 bucket for saving a query results file (.csv) and a metadata file (.csv.metadata)
pollingInterval 1000 Optional. Interval of polling sql results (ms)
queryTimeout 0 Optional. Timeout of query execution. 0 is no timeout
database 'default' Optional. The name of the database within which the query executes
baseRetryWait 200 Optional. Used to calculate retry timeout for a particular query execution request
retryWaitMax 10000 Optional. Maximum retry timeout for starting a new query execution
retryCountMax 10 Optional. Maximum number of retry attempts for a particular query execution request
execRightCheckInterval 100 Optional. Timeout when number of maximum concurrent requests is exceeded
encryptionOption undefined Optional. Indicates the S3 encryption option used to encrypt the query results. Possible values include: SSE_S3, SSE_KMS, or CSE_KMS
encryptionKmsKey undefined Optional but required if encryptionOption is set to SSE_KMS or CSE_KMS. Value is the KMS key ARN or ID
skipFetchResult false Optional. If true, do not return the result of the query when the athena query is finished. This option is used for CTAS
concurrentExecMax 5 DEPRECATED. Use athena.setConcurrentExecMax() instead
workGroup 'primary' Optional. The name of the workgroup within which the query executes

awsConfig object properties

Property Default Description
region Required Your Athena and S3 region
accessKeyId undefined Optional. Your IAM accessKeyId
secretAccessKey undefined Optional. Your IAM secretAccessKey

client.execute([query], [callback])

It will return the following result. If you want to know more about params of queryExecution, please refer to the aws-sdk document

{
    "records": [
        {"_col0:": "1"}
    ],
    "queryExecution": {
        "Query": "SELECT 1", 
        "QueryExecutionId": "55571bb9-8e4e-4274-90b7-8cffe4539c3c", 
        "ResultConfiguration": {
            "OutputLocation": "s3://bucket/55571bb9-8e4e-4274-90b7-8cffe4539c3c"
        }, 
        "Statistics": {
            "DataScannedInBytes": 0, 
            "EngineExecutionTimeInMillis": 137
        }, 
        "Status": {
            "CompletionDateTime": "2017-12-31T16:03:53.493Z", 
            "State": "SUCCEEDED", 
            "SubmissionDateTime": "2017-12-31T16:03:53.209Z"
        }
    }
}

client.execute([query]).toPromise()

Returns a Promise that resolves the result of your query.

client.execute([query]).toStream()

Returns a Stream to buffer the results of your query. This method is recommended for large result sets.

// Get record one by one
stream.on('data', function(record) {
  console.log(record) // {"col1": "val1", "col2": "val2"}
})

// When query succeed, this event will emit.
stream.on('query_end', function(queryExecution) {
  console.log(queryExecution) // {"QueryExecutionId": "", ...}
})

stream.on('end', function() {
  console.log('end')
})
stream.on('error', function(e) {
  console.error(e)
})
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].