Reputation: 192
I am trying to run a simple athena query and trying to save the results to a local path.
response = athena.start_query_execution(
QueryString='select query',
QueryExecutionContext={
'Database': 'test'
},
ResultConfiguration={
'OutputLocation': r'C:\Projects\Project0\'
}
But I am getting the below error.
botocore.errorfactory.InvalidRequestException: An error occurred (InvalidRequestException) when calling the StartQueryExecution operation: outputLocation is not a valid S3 path.
Is it possible to save the results to local path? I couldnt find any information in boto3 docs.
Upvotes: 2
Views: 4156
Reputation: 5124
In Athena results only can be saved to s3 location.Please refer to OutputLocation to know more about the semantics.If you want this result in your local system then you can go to the s3 location which you have provided as input to your start_query_execution API call and download result from s3 console or use aws s3 cp command
Upvotes: 0
Reputation: 241
ResultConfiguration does not contain the result of your query. You have to make a second call using 'QueryExecutionId' and the get_query_results
function:
exe = athena.start_query_execution(
QueryString='select query',
QueryExecutionContext={
'Database': 'test'
},
ResultConfiguration={
'OutputLocation': 's3 location'
}
result = athena.get_query_results(
QueryExecutionId=exe['QueryExecutionId']
)
Upvotes: 2