Skip to content

Latest commit

History

History
81 lines (60 loc) 路 3.01 KB

NODE_API.md

File metadata and controls

81 lines (60 loc) 路 3.01 KB

Table of Contents

owl

An instance of the client.

Parameters

  • opts object Options to the constructor
    • opts.accessKeyId string AWS Access Key ID
    • opts.secretAccessKey string AWS corresponding AWS secret key
    • opts.region string AWS region (optional, default us-east-1)
    • opts.outputBucket string S3 location to store the results of queries (optional, default s3://little-owl-athena-output)

Examples

const owl = require('little-owl')({
  accessKeyId: 'MY-AWS-ID',
  secretAccessKey: 'MY-AWS-SECRET'
})

submitQuery

Submit a query and waits until it returns.

Parameters

  • queryString string SQL statement
  • callback submitQueryCallback node callback (err, queryId)

Examples

owl.submitQuery('SELECT * from owls', (err, queryId) => {
  if (!err) {
    console.log(queryId); // prints the query id
  }
});

getQueryResults

Get results from a submitted query. The return object contains: results: the results are an array of rows, each row an array of strings. nextToken: if the number of results is larger than maxRows, use nextToken to return the next set of values

Parameters

  • queryId string Id of query
  • opts object? Options
    • opts.maxRows number maximum number of rows returned (optional, default 1000)
    • opts.nextToken string? used for paginated results
  • callback getQueryResultCallback node callback (err, results)

Examples

owl.getQueryResults('x2x4gas-12qwsd-a809', (err, data) => {
  if (!err) {
     console.log(data.results); // results is an array of rows
     console.log(data.nextToken); // data.nextToken is used for pagination
  }
});
owl.getQueryResults('x2x4gas-12qwsd-a809', {nextToken: '91kaspejk13'}, (err, data) => {
  if (!err) {
     console.log(data.results); // results is an array of rows
  }
});