Python boto3 Athena查询开始执行请求中包含的安全令牌无效

2024-10-06 10:21:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我获取雅典娜查询的代码是

    self.athenaDataSource = "AwsCatalog"
    self.athenaDB = "prod_myapp_app"
    self.athenaResultBucket = "s3://s3-athena-prod-results/"
    

这里我展示了如何创建客户机和call.start\u query\u执行

    clientAthena = boto3.client('athena', region_name=awsRegion)
    athenaQueryExecResp = clientAthena.start_query_execution(
        QueryString=self.athenaQuery,
        QueryExecutionContext={ 'Database': self.athenaDB },
        ResultConfiguration={'OutputLocation': self.athenaResultBucket }
    )
    print("athenaQueryExecResp= "+str(athenaQueryExecResp))
    

我得到这个错误

botocore.exceptions.ClientError: An error occurred (UnrecognizedClientException) when calling the StartQueryExecution operation: The security token included in the request is invalid.

问题是,这意味着我没有通过正确的安全性,但我如何传递凭据。我检查了https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/athena.html#Athena.Client.start_query_execution它从来没有提到任何关于传递凭证、安全访问和令牌的事情


Tags: the代码selfs3prodboto3querystart