gpt4 book ai didi

python - Athena 查询因 boto3 而失败(S3 位置无效)

转载 作者:太空宇宙 更新时间:2023-11-04 06:59:43 24 4
gpt4 key购买 nike

我尝试在 Athena 中执行查询,但失败了。

代码:

client.start_query_execution(QueryString="CREATE DATABASE IF NOT EXISTS db;",
QueryExecutionContext={'Database': 'db'},
ResultConfiguration={
'OutputLocation': "s3://my-bucket/",
'EncryptionConfiguration': {
'EncryptionOption': 'SSE-S3'
}
})

但它引发了以下异常:

botocore.errorfactory.InvalidRequestException: An error occurred (InvalidRequestException) 
when calling the StartQueryExecution operation: The S3 location provided to save your
query results is invalid. Please check your S3 location is correct and is in the same
region and try again. If you continue to see the issue, contact customer support
for further assistance.

但是,如果我转到 Athena 控制台,转到“设置”并输入相同的 S3 位置(例如):

athena settings

查询运行良好。

我的代码有什么问题?我已经成功地使用了其他几个服务(例如 S3)的 API,但是在这个服务中我相信我传递了一些不正确的参数。谢谢。

python :3.6.1。 Boto3:1.4.4

最佳答案

我必须向我的存储桶添加“athena-”前缀才能使其正常工作。例如,代替:

“s3://我的桶/”

尝试:

“s3://athena-my-bucket/”

关于python - Athena 查询因 boto3 而失败(S3 位置无效),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45313763/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com