RDSdataService execute_statement 返回 (BadRequestException) [英] RDSdataService execute_statement returns (BadRequestException)

查看:26
本文介绍了RDSdataService execute_statement 返回 (BadRequestException)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有 executeStatement 的 boto3 库来使用 DATA API 从 RDS 集群获取数据.如果我选择 1 或 2 列,查询工作正常,但是一旦我选择另一列进行查询,它就会返回一个错误,(BadRequestException) 权限被拒绝用于关系 table_name

I am using boto3 library with executeStatement to get data from an RDS cluster using DATA API. Query is working fine if i select 1 or 2 columns but as soon as I select another column to query, it returns an error with (BadRequestException) permission denied for relation table_name

我已经使用 pgadmin 检查了权限是否完整,可以查询我正在使用的用户的整个数据库.

I have checked using pgadmin the permissions are intact to query the whole db for the user I am using.

调用中包含的函数:

def execute_query(self, sql_query, sql_parameters=[]):
        """
        Aurora DataAPI execute query. Generally used for select statements.
        :param sql_query: Query
        :param sql_parameters: parameters in sql query
        :return: DataApi response
        """
        client = self.api_access()
        response = client.execute_statement(
            resourceArn=RESOURCE_ARN,
            secretArn=SECRET_ARN,
            database='db_name',
            sql=sql_query,
            includeResultMetadata=True,
            parameters=sql_parameters)
        return response

函数调用:没有错误

    query = '''
        SELECT id
        FROM schema_name.table_name
        limit 1

    ''' 
    print(query)
    result = conn.execute_query(query)
    print(result)

函数调用:因上述错误而失败

function call: fails with above error

    query = '''
        SELECT id,name,event
        FROM schema_name.table_name
        limit 1

    ''' 
    print(query)
    result = conn.execute_query(query)
    print(result)

使用 Boto3 从 DATA API 获取的内容是否有横向限制?我知道 1MB 有限制,但如果超过限制,它应该根据文档返回一些内容.

Is there a horizontal limit on what we can get from DATA API using Boto3? I know there is a limit for 1MB, but it should return something as per the documentation if it exceeds the limit.

后端是Postgres RDS

更新:我可以选择相同的列 10 次,这不是问题

UPDATE: I can select the same columns 10 times and its not a problem

    query = '''
        SELECT id,event,event,event,event,event
        FROM schema_name.table_name
        limit 1

    ''' 
    print(query)
    result = conn.execute_query(query)
    print(result)

所以这意味着有些列我无法选择.

So this means there are some columns that I cannot select.

推荐答案

我不知道某些表中有列级安全性.如果您使用的用户在 postgres 中有列级证券,那很明显我无法选择这些列.

I didnt know there are column level security in some tables. If there are column level securities in postgres for the user you are using that's obvious I cannot select those columns.

这篇关于RDSdataService execute_statement 返回 (BadRequestException)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆