[英]Run aws Athena query by Lambda: error name 'response' is not defined
[英]AWS Lambda Query Athena and chose name of result file
我正在执行一个 Python 脚本,该脚本在 AWS Lambda 中的 AWS Athena 上运行查询。 结果作为 csv 和元数据文件发送到我的 s3 存储桶。 这是脚本:
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)
代码工作正常,但我想在 s3 中选择生成的 csv 文件的名称。 关于我如何做到这一点的任何想法?
谢谢你的帮助。
没有办法将 select 命名为 output 文件,该名称的格式为<QueryExecutionId>.csv
。 然后,您可以使用 s3 api 重命名 output 文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.