I sometimes connect to Athena with AWS CLI on windows command line, Anyway I wanted to get the query result and draw the graph, so I thought I would do it with python. There was a dead end in the named profile part, so organize it
aws athena start-query-execution
--query-string "select * from table_name"
--result-configuration "s3://path/to/query/bucket/"
AWS documentation: https://docs.aws.amazon.com/cli/latest/reference/athena/start-query-execution.html
athena = boto3.client('athena')
#Query execution
exec_run = athena.start_query_execution(
QueryString="select * from table_name",
QueryExecutionContext={'Database': 'database_name'},
ResultConfiguration={'OutputLocation': 's3://path/to/query/bucket/'})
AWS documentation: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/athena.html
I want to execute a query using the information of the named profile.
How to set up a named profile I wasted my time without noticing the difference between "windows command line" and "python".
How to set up a named profile windows command line: set as a parameter of the aws command python: Set profile information using boto3.session class
aws athena start-query-execution
--query-string "select * from table_name"
--result-configuration "s3://path/to/query/bucket/"
--profile "NRP"
AWS documentation: https://docs.aws.amazon.com/cli/latest/reference/athena/start-query-execution.html https://docs.aws.amazon.com/cli/latest/reference/athena/start-query-execution.html
session = boto3.Session(profile_name='NRP')
athena = session.client('athena')
#Processing execution
exec_run = athena.start_query_execution(
QueryString="select * from table_name",
QueryExecutionContext={'Database': 'database_name'},
ResultConfiguration={'OutputLocation': 's3://path/to/query/bucket/'})
AWS documentation: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/athena.html https://boto3.amazonaws.com/v1/documentation/api/latest/guide/session.html Articles about S3 connectivity: Use something other than the default profile with boto3
It was hard to get to boto3.session. It wasn't good to look it up on an error statement basis. It was written firmly in the manual Once I got there, I realized again that I would understand various things.
However, this time there are many issues such as not having all the acquisition results.
that's all.
Described in each place
Recommended Posts