Zepl
Search…
Amazon Athena

  1. 1.
    Navigate to: Resources > Data Sources
  2. 2.
    Select the Amazon Athena Icon:

  • Name (required)
  • Description (optional)
  • Region name (required):
    • This should correspond to the region where your data is stored in S3
    • Example: us-west-1
  • Credential Type: See Data Source Security​
  • Access key ID:
  • Secret access key:

Python
%python
​
# Connect to Athena. Returns: botocore.client.Athena object
client = z.getDatasource("zepl_docs_athena")
​
# Set parameter values for query execution
params = {
'region': 'us-west-1',
'database': 'default',
'bucket': 'shainsky-athena-demo',
'path': 'athena_queries',
'query': ( """ SELECT os, COUNT(*) count
FROM default.cloudfront_logs
WHERE date BETWEEN date '2014-07-05' AND date '2014-08-05'
GROUP BY os
""")
}
​
# Execute query in athena and return result files to the S3 bucket specificed at OutputLocation path
response = client.start_query_execution(
QueryString=params['query'],
QueryExecutionContext={
'Database': params['database']
},
ResultConfiguration={
'OutputLocation': 's3://' + params['bucket'] + '/' + params['path']
}
)
Use z.getDatasource() to return Botocore Athena client object: botocore.client.Athena​

  1. 1.
    Login to AWS
  2. 2.
    Navigate to IAM > Users
  3. 3.
    Select your user name
  4. 4.
    Select Add permissions, to make sure your user has the required permissions to support the level of access required. AmazonAthenaFullAccess - Grants access to all actions and all resources
  5. 5.
    Select Security credentials > Create access key
  6. 6.
    Download .csv file - This file contains the key that will be entered into Zepl's Athena Data Source. DO NOT LOSE THIS file.
Copy link
On this page
Create an Amazon Athena Datasource
Data Source Inputs
Use Amazon Athena
Read
Open all examples in Zepl
Configure Authentication