Reputation: 87
I am doing a Python script that runs a query on AWS Athena in AWS Lambda. The result are sent to my s3 bucket as csv and metadata files. Here is the script :
def lambda_handler(event, context):
client = boto3.client('athena')
QueryResponse = client.start_query_execution(
QueryString = "SELECT id from campaign;",
QueryExecutionContext = {
'Database' : 'raw'
},
ResultConfiguration = {
'OutputLocation' : 's3://my-bucket-name'
}
)
#Oberserve results :
queryId = QueryResponse['QueryExecutionId']
time.sleep(10)
results = client.get_query_results(QueryExecutionId = queryId)
for row in results['ResultSet']['Rows']:
print(row)
The code works fine, but I would like to choose the name of the resulting csv file in s3. Any ideas on how I could do that ?
Thank's for helping.
Upvotes: 1
Views: 1603
Reputation: 1305
There isn't a way to select the name output file, the name is formed as <QueryExecutionId>.csv
. You can then rename the output file using the s3 api.
Upvotes: 1