execute_and_save_query: Execute a Query and Save it to disk

Description Usage Arguments Details Value References Examples

Description

This funciton combines the start_query_execution with the save_query_results function to execute, run, and retrieve the results of a SQL query on Athena.

Usage

1
2
3
4
5
6
execute_and_save_query(query, database, output_location, local_filename,
  client_request_token = NULL, encryption_option = NULL,
  kms_key = NULL, aws_access_key_id = NULL,
  aws_secret_access_key = NULL, aws_session_token = NULL,
  region_name = NULL, profile_name = NULL, polling_duration = 15,
  checktime = FALSE, maxtime = 1000)

Arguments

query

SQL query statements to be executed

database

database within which the query executes.

output_location

location in S3 where query results are stored.

local_filename

download location of the athena result

client_request_token

unique case-sensitive string used to ensure the request to create the query is idempotent (executes only once). If another StartQueryExecution request is received, the same response is returned and another query is not created. If a parameter has changed, for example, the query , an error is returned. This is auto-generated-for-you.

encryption_option

indicates whether Amazon S3 server-side encryption with Amazon S3-managed keys (SSE-S3), server-side encryption with KMS-managed keys (SSE-KMS), or client-side encryption with KMS-managed keys (CSE-KMS) is used. Default is NULL (no encryption)

kms_key

For SSE-KMS and CSE-KMS, this is the KMS key ARN or ID. Default is NULL (no encryption)

aws_access_key_id

AWS access key id

aws_secret_access_key

AWS secret access key

aws_session_token

AWS session token

region_name

region name

polling_duration

how often to check for results

checktime

whether to check for time

profile

profile name

max_time

how long to keep looking for data

Details

This is useful for downloading large results where it is undesireable to load the full dataset into memory.

Value

the filename

References

https://boto3.readthedocs.io/en/latest/reference/services/athena.html#Athena.Client.get_query_results

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
execute_and_save_query(
  query    = "SELECT * FROM elb_logs LIMIT 100",
  database = "sampledb",
  profile  = "personal",
  output_location = "s3://aws-athena-query-results-redacted",
  local_filename = "download-to-here.csv",
  polling_duration = 15,
  checktime=FALSE,
  maxtime=1000
  )

## End(Not run)

hrbrmstr/roto.athena documentation built on May 29, 2019, 11:42 a.m.