RDSDataService / Client / execute_sql

execute_sql#

RDSDataService.Client.execute_sql(**kwargs)#

Runs one or more SQL statements.

Note

This operation isn’t supported for Aurora Serverless v2 and provisioned DB clusters. For Aurora Serverless v1 DB clusters, the operation is deprecated. Use the BatchExecuteStatement or ExecuteStatement operation.

Danger

This operation is deprecated and may not function as expected. This operation should not be used going forward and is only kept for the purpose of backwards compatiblity.

See also: AWS API Documentation

Request Syntax

response = client.execute_sql(
    dbClusterOrInstanceArn='string',
    awsSecretStoreArn='string',
    sqlStatements='string',
    database='string',
    schema='string'
)
Parameters:
  • dbClusterOrInstanceArn (string) –

    [REQUIRED]

    The ARN of the Aurora Serverless DB cluster.

  • awsSecretStoreArn (string) –

    [REQUIRED]

    The Amazon Resource Name (ARN) of the secret that enables access to the DB cluster. Enter the database user name and password for the credentials in the secret.

    For information about creating the secret, see Create a database secret.

  • sqlStatements (string) –

    [REQUIRED]

    One or more SQL statements to run on the DB cluster.

    You can separate SQL statements from each other with a semicolon (;). Any valid SQL statement is permitted, including data definition, data manipulation, and commit statements.

  • database (string) – The name of the database.

  • schema (string) – The name of the database schema.

Return type:

dict

Returns:

Response Syntax

{
    'sqlStatementResults': [
        {
            'resultFrame': {
                'resultSetMetadata': {
                    'columnCount': 123,
                    'columnMetadata': [
                        {
                            'name': 'string',
                            'type': 123,
                            'typeName': 'string',
                            'label': 'string',
                            'schemaName': 'string',
                            'tableName': 'string',
                            'isAutoIncrement': True|False,
                            'isSigned': True|False,
                            'isCurrency': True|False,
                            'isCaseSensitive': True|False,
                            'nullable': 123,
                            'precision': 123,
                            'scale': 123,
                            'arrayBaseColumnType': 123
                        },
                    ]
                },
                'records': [
                    {
                        'values': [
                            {
                                'isNull': True|False,
                                'bitValue': True|False,
                                'bigIntValue': 123,
                                'intValue': 123,
                                'doubleValue': 123.0,
                                'realValue': ...,
                                'stringValue': 'string',
                                'blobValue': b'bytes',
                                'arrayValues': [
                                    {'... recursive ...'},
                                ],
                                'structValue': {
                                    'attributes': [
                                        {'... recursive ...'},
                                    ]
                                }
                            },
                        ]
                    },
                ]
            },
            'numberOfRecordsUpdated': 123
        },
    ]
}

Response Structure

  • (dict) –

    The response elements represent the output of a request to run one or more SQL statements.

    • sqlStatementResults (list) –

      The results of the SQL statement or statements.

      • (dict) –

        The result of a SQL statement.

        Note

        This data structure is only used with the deprecated ExecuteSql operation. Use the BatchExecuteStatement or ExecuteStatement operation instead.

        • resultFrame (dict) –

          The result set of the SQL statement.

          • resultSetMetadata (dict) –

            The result-set metadata in the result set.

            • columnCount (integer) –

              The number of columns in the result set.

            • columnMetadata (list) –

              The metadata of the columns in the result set.

              • (dict) –

                Contains the metadata for a column.

                • name (string) –

                  The name of the column.

                • type (integer) –

                  The type of the column.

                • typeName (string) –

                  The database-specific data type of the column.

                • label (string) –

                  The label for the column.

                • schemaName (string) –

                  The name of the schema that owns the table that includes the column.

                • tableName (string) –

                  The name of the table that includes the column.

                • isAutoIncrement (boolean) –

                  A value that indicates whether the column increments automatically.

                • isSigned (boolean) –

                  A value that indicates whether an integer column is signed.

                • isCurrency (boolean) –

                  A value that indicates whether the column contains currency values.

                • isCaseSensitive (boolean) –

                  A value that indicates whether the column is case-sensitive.

                • nullable (integer) –

                  A value that indicates whether the column is nullable.

                • precision (integer) –

                  The precision value of a decimal number column.

                • scale (integer) –

                  The scale value of a decimal number column.

                • arrayBaseColumnType (integer) –

                  The type of the column.

          • records (list) –

            The records in the result set.

            • (dict) –

              A record returned by a call.

              Note

              This data structure is only used with the deprecated ExecuteSql operation. Use the BatchExecuteStatement or ExecuteStatement operation instead.

              • values (list) –

                The values returned in the record.

                • (dict) –

                  Contains the value of a column.

                  Note

                  This data structure is only used with the deprecated ExecuteSql operation. Use the BatchExecuteStatement or ExecuteStatement operation instead.

                  Note

                  This is a Tagged Union structure. Only one of the following top level keys will be set: isNull, bitValue, bigIntValue, intValue, doubleValue, realValue, stringValue, blobValue, arrayValues, structValue. If a client receives an unknown member it will set SDK_UNKNOWN_MEMBER as the top level key, which maps to the name or tag of the unknown member. The structure of SDK_UNKNOWN_MEMBER is as follows:

                  'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
                  
                  • isNull (boolean) –

                    A NULL value.

                  • bitValue (boolean) –

                    A value for a column of BIT data type.

                  • bigIntValue (integer) –

                    A value for a column of big integer data type.

                  • intValue (integer) –

                    A value for a column of integer data type.

                  • doubleValue (float) –

                    A value for a column of double data type.

                  • realValue (float) –

                    A value for a column of real data type.

                  • stringValue (string) –

                    A value for a column of string data type.

                  • blobValue (bytes) –

                    A value for a column of BLOB data type.

                  • arrayValues (list) –

                    An array of column values.

                    • (dict) –

                      Contains the value of a column.

                      Note

                      This data structure is only used with the deprecated ExecuteSql operation. Use the BatchExecuteStatement or ExecuteStatement operation instead.

                      Note

                      This is a Tagged Union structure. Only one of the following top level keys will be set: isNull, bitValue, bigIntValue, intValue, doubleValue, realValue, stringValue, blobValue, arrayValues, structValue. If a client receives an unknown member it will set SDK_UNKNOWN_MEMBER as the top level key, which maps to the name or tag of the unknown member. The structure of SDK_UNKNOWN_MEMBER is as follows:

                      'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
                      
                  • structValue (dict) –

                    A value for a column of STRUCT data type.

                    • attributes (list) –

                      The attributes returned in the record.

                      • (dict) –

                        Contains the value of a column.

                        Note

                        This data structure is only used with the deprecated ExecuteSql operation. Use the BatchExecuteStatement or ExecuteStatement operation instead.

                        Note

                        This is a Tagged Union structure. Only one of the following top level keys will be set: isNull, bitValue, bigIntValue, intValue, doubleValue, realValue, stringValue, blobValue, arrayValues, structValue. If a client receives an unknown member it will set SDK_UNKNOWN_MEMBER as the top level key, which maps to the name or tag of the unknown member. The structure of SDK_UNKNOWN_MEMBER is as follows:

                        'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
                        
        • numberOfRecordsUpdated (integer) –

          The number of records updated by a SQL statement.

Exceptions

  • RDSDataService.Client.exceptions.AccessDeniedException

  • RDSDataService.Client.exceptions.BadRequestException

  • RDSDataService.Client.exceptions.InternalServerErrorException

  • RDSDataService.Client.exceptions.ForbiddenException

  • RDSDataService.Client.exceptions.ServiceUnavailableError