AWS RDS DataService

2021/02/03 - AWS RDS DataService - 2 updated api methods

Changes  With the Data API, you can now use UUID and JSON data types as input to your database. Also with the Data API, you can now have a LONG type value returned from your database as a STRING value.

BatchExecuteStatement (updated) Link ¶
Changes (request)
{'parameterSets': {'typeHint': {'JSON', 'UUID'}}}

Runs a batch SQL statement over an array of data.

You can run bulk update and insert operations for multiple records using a DML statement with different parameter sets. Bulk operations can provide a significant performance improvement over individual insert and update operations.

Warning

If a call isn't part of a transaction because it doesn't include the transactionID parameter, changes that result from the call are committed automatically.

See also: AWS API Documentation

Request Syntax

client.batch_execute_statement(
    database='string',
    parameterSets=[
        [
            {
                'name': 'string',
                'typeHint': 'JSON'|'UUID'|'TIMESTAMP'|'DATE'|'TIME'|'DECIMAL',
                'value': {
                    'arrayValue': {
                        'arrayValues': [
                            {'... recursive ...'},
                        ],
                        'booleanValues': [
                            True|False,
                        ],
                        'doubleValues': [
                            123.0,
                        ],
                        'longValues': [
                            123,
                        ],
                        'stringValues': [
                            'string',
                        ]
                    },
                    'blobValue': b'bytes',
                    'booleanValue': True|False,
                    'doubleValue': 123.0,
                    'isNull': True|False,
                    'longValue': 123,
                    'stringValue': 'string'
                }
            },
        ],
    ],
    resourceArn='string',
    schema='string',
    secretArn='string',
    sql='string',
    transactionId='string'
)
type database

string

param database

The name of the database.

type parameterSets

list

param parameterSets

The parameter set for the batch operation.

The SQL statement is executed as many times as the number of parameter sets provided. To execute a SQL statement with no parameters, use one of the following options:

  • Specify one or more empty parameter sets.

  • Use the ExecuteStatement operation instead of the BatchExecuteStatement operation.

Note

Array parameters are not supported.

  • (list) --

    • (dict) --

      A parameter used in a SQL statement.

      • name (string) --

        The name of the parameter.

      • typeHint (string) --

        A hint that specifies the correct object type for data type mapping. Possible values are as follows:

        • DATE - The corresponding String parameter value is sent as an object of DATE type to the database. The accepted format is YYYY-MM-DD .

        • DECIMAL - The corresponding String parameter value is sent as an object of DECIMAL type to the database.

        • JSON - The corresponding String parameter value is sent as an object of JSON type to the database.

        • TIME - The corresponding String parameter value is sent as an object of TIME type to the database. The accepted format is HH:MM:SS[.FFF] .

        • TIMESTAMP - The corresponding String parameter value is sent as an object of TIMESTAMP type to the database. The accepted format is YYYY-MM-DD HH:MM:SS[.FFF] .

        • UUID - The corresponding String parameter value is sent as an object of UUID type to the database.

      • value (dict) --

        The value of the parameter.

        Note

        This is a Tagged Union structure. Only one of the following top level keys can be set: arrayValue, blobValue, booleanValue, doubleValue, isNull, longValue, stringValue.

        • arrayValue (dict) --

          An array of values.

          Note

          This is a Tagged Union structure. Only one of the following top level keys can be set: arrayValues, booleanValues, doubleValues, longValues, stringValues.

          • arrayValues (list) --

            An array of arrays.

            • (dict) --

              Contains an array.

              Note

              This is a Tagged Union structure. Only one of the following top level keys can be set: arrayValues, booleanValues, doubleValues, longValues, stringValues.

          • booleanValues (list) --

            An array of Boolean values.

            • (boolean) --

          • doubleValues (list) --

            An array of integers.

            • (float) --

          • longValues (list) --

            An array of floating point numbers.

            • (integer) --

          • stringValues (list) --

            An array of strings.

            • (string) --

        • blobValue (bytes) --

          A value of BLOB data type.

        • booleanValue (boolean) --

          A value of Boolean data type.

        • doubleValue (float) --

          A value of double data type.

        • isNull (boolean) --

          A NULL value.

        • longValue (integer) --

          A value of long data type.

        • stringValue (string) --

          A value of string data type.

type resourceArn

string

param resourceArn

[REQUIRED]

The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.

type schema

string

param schema

The name of the database schema.

type secretArn

string

param secretArn

[REQUIRED]

The name or ARN of the secret that enables access to the DB cluster.

type sql

string

param sql

[REQUIRED]

The SQL statement to run.

type transactionId

string

param transactionId

The identifier of a transaction that was started by using the BeginTransaction operation. Specify the transaction ID of the transaction that you want to include the SQL statement in.

If the SQL statement is not part of a transaction, don't set this parameter.

rtype

dict

returns

Response Syntax

{
    'updateResults': [
        {
            'generatedFields': [
                {
                    'arrayValue': {
                        'arrayValues': [
                            {'... recursive ...'},
                        ],
                        'booleanValues': [
                            True|False,
                        ],
                        'doubleValues': [
                            123.0,
                        ],
                        'longValues': [
                            123,
                        ],
                        'stringValues': [
                            'string',
                        ]
                    },
                    'blobValue': b'bytes',
                    'booleanValue': True|False,
                    'doubleValue': 123.0,
                    'isNull': True|False,
                    'longValue': 123,
                    'stringValue': 'string'
                },
            ]
        },
    ]
}

Response Structure

  • (dict) --

    The response elements represent the output of a SQL statement over an array of data.

    • updateResults (list) --

      The execution results of each batch entry.

      • (dict) --

        The response elements represent the results of an update.

        • generatedFields (list) --

          Values for fields generated during the request.

          • (dict) --

            Contains a value.

            Note

            This is a Tagged Union structure. Only one of the following top level keys will be set: arrayValue, blobValue, booleanValue, doubleValue, isNull, longValue, stringValue. 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'}
            • arrayValue (dict) --

              An array of values.

              Note

              This is a Tagged Union structure. Only one of the following top level keys will be set: arrayValues, booleanValues, doubleValues, longValues, stringValues. 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'}
              • arrayValues (list) --

                An array of arrays.

                • (dict) --

                  Contains an array.

                  Note

                  This is a Tagged Union structure. Only one of the following top level keys will be set: arrayValues, booleanValues, doubleValues, longValues, stringValues. 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'}
              • booleanValues (list) --

                An array of Boolean values.

                • (boolean) --

              • doubleValues (list) --

                An array of integers.

                • (float) --

              • longValues (list) --

                An array of floating point numbers.

                • (integer) --

              • stringValues (list) --

                An array of strings.

                • (string) --

            • blobValue (bytes) --

              A value of BLOB data type.

            • booleanValue (boolean) --

              A value of Boolean data type.

            • doubleValue (float) --

              A value of double data type.

            • isNull (boolean) --

              A NULL value.

            • longValue (integer) --

              A value of long data type.

            • stringValue (string) --

              A value of string data type.

ExecuteStatement (updated) Link ¶
Changes (request)
{'parameters': {'typeHint': {'JSON', 'UUID'}}}

Runs a SQL statement against a database.

Warning

If a call isn't part of a transaction because it doesn't include the transactionID parameter, changes that result from the call are committed automatically.

The response size limit is 1 MB. If the call returns more than 1 MB of response data, the call is terminated.

See also: AWS API Documentation

Request Syntax

client.execute_statement(
    continueAfterTimeout=True|False,
    database='string',
    includeResultMetadata=True|False,
    parameters=[
        {
            'name': 'string',
            'typeHint': 'JSON'|'UUID'|'TIMESTAMP'|'DATE'|'TIME'|'DECIMAL',
            'value': {
                'arrayValue': {
                    'arrayValues': [
                        {'... recursive ...'},
                    ],
                    'booleanValues': [
                        True|False,
                    ],
                    'doubleValues': [
                        123.0,
                    ],
                    'longValues': [
                        123,
                    ],
                    'stringValues': [
                        'string',
                    ]
                },
                'blobValue': b'bytes',
                'booleanValue': True|False,
                'doubleValue': 123.0,
                'isNull': True|False,
                'longValue': 123,
                'stringValue': 'string'
            }
        },
    ],
    resourceArn='string',
    resultSetOptions={
        'decimalReturnType': 'STRING'|'DOUBLE_OR_LONG'
    },
    schema='string',
    secretArn='string',
    sql='string',
    transactionId='string'
)
type continueAfterTimeout

boolean

param continueAfterTimeout

A value that indicates whether to continue running the statement after the call times out. By default, the statement stops running when the call times out.

Warning

For DDL statements, we recommend continuing to run the statement after the call times out. When a DDL statement terminates before it is finished running, it can result in errors and possibly corrupted data structures.

type database

string

param database

The name of the database.

type includeResultMetadata

boolean

param includeResultMetadata

A value that indicates whether to include metadata in the results.

type parameters

list

param parameters

The parameters for the SQL statement.

Note

Array parameters are not supported.

  • (dict) --

    A parameter used in a SQL statement.

    • name (string) --

      The name of the parameter.

    • typeHint (string) --

      A hint that specifies the correct object type for data type mapping. Possible values are as follows:

      • DATE - The corresponding String parameter value is sent as an object of DATE type to the database. The accepted format is YYYY-MM-DD .

      • DECIMAL - The corresponding String parameter value is sent as an object of DECIMAL type to the database.

      • JSON - The corresponding String parameter value is sent as an object of JSON type to the database.

      • TIME - The corresponding String parameter value is sent as an object of TIME type to the database. The accepted format is HH:MM:SS[.FFF] .

      • TIMESTAMP - The corresponding String parameter value is sent as an object of TIMESTAMP type to the database. The accepted format is YYYY-MM-DD HH:MM:SS[.FFF] .

      • UUID - The corresponding String parameter value is sent as an object of UUID type to the database.

    • value (dict) --

      The value of the parameter.

      Note

      This is a Tagged Union structure. Only one of the following top level keys can be set: arrayValue, blobValue, booleanValue, doubleValue, isNull, longValue, stringValue.

      • arrayValue (dict) --

        An array of values.

        Note

        This is a Tagged Union structure. Only one of the following top level keys can be set: arrayValues, booleanValues, doubleValues, longValues, stringValues.

        • arrayValues (list) --

          An array of arrays.

          • (dict) --

            Contains an array.

            Note

            This is a Tagged Union structure. Only one of the following top level keys can be set: arrayValues, booleanValues, doubleValues, longValues, stringValues.

        • booleanValues (list) --

          An array of Boolean values.

          • (boolean) --

        • doubleValues (list) --

          An array of integers.

          • (float) --

        • longValues (list) --

          An array of floating point numbers.

          • (integer) --

        • stringValues (list) --

          An array of strings.

          • (string) --

      • blobValue (bytes) --

        A value of BLOB data type.

      • booleanValue (boolean) --

        A value of Boolean data type.

      • doubleValue (float) --

        A value of double data type.

      • isNull (boolean) --

        A NULL value.

      • longValue (integer) --

        A value of long data type.

      • stringValue (string) --

        A value of string data type.

type resourceArn

string

param resourceArn

[REQUIRED]

The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.

type resultSetOptions

dict

param resultSetOptions

Options that control how the result set is returned.

  • decimalReturnType (string) --

    A value that indicates how a field of DECIMAL type is represented in the response. The value of STRING , the default, specifies that it is converted to a String value. The value of DOUBLE_OR_LONG specifies that it is converted to a Long value if its scale is 0, or to a Double value otherwise.

    Warning

    Conversion to Double or Long can result in roundoff errors due to precision loss. We recommend converting to String, especially when working with currency values.

type schema

string

param schema

The name of the database schema.

Note

Currently, the schema parameter isn't supported.

type secretArn

string

param secretArn

[REQUIRED]

The name or ARN of the secret that enables access to the DB cluster.

type sql

string

param sql

[REQUIRED]

The SQL statement to run.

type transactionId

string

param transactionId

The identifier of a transaction that was started by using the BeginTransaction operation. Specify the transaction ID of the transaction that you want to include the SQL statement in.

If the SQL statement is not part of a transaction, don't set this parameter.

rtype

dict

returns

Response Syntax

{
    'columnMetadata': [
        {
            'arrayBaseColumnType': 123,
            'isAutoIncrement': True|False,
            'isCaseSensitive': True|False,
            'isCurrency': True|False,
            'isSigned': True|False,
            'label': 'string',
            'name': 'string',
            'nullable': 123,
            'precision': 123,
            'scale': 123,
            'schemaName': 'string',
            'tableName': 'string',
            'type': 123,
            'typeName': 'string'
        },
    ],
    'generatedFields': [
        {
            'arrayValue': {
                'arrayValues': [
                    {'... recursive ...'},
                ],
                'booleanValues': [
                    True|False,
                ],
                'doubleValues': [
                    123.0,
                ],
                'longValues': [
                    123,
                ],
                'stringValues': [
                    'string',
                ]
            },
            'blobValue': b'bytes',
            'booleanValue': True|False,
            'doubleValue': 123.0,
            'isNull': True|False,
            'longValue': 123,
            'stringValue': 'string'
        },
    ],
    'numberOfRecordsUpdated': 123,
    'records': [
        [
            {
                'arrayValue': {
                    'arrayValues': [
                        {'... recursive ...'},
                    ],
                    'booleanValues': [
                        True|False,
                    ],
                    'doubleValues': [
                        123.0,
                    ],
                    'longValues': [
                        123,
                    ],
                    'stringValues': [
                        'string',
                    ]
                },
                'blobValue': b'bytes',
                'booleanValue': True|False,
                'doubleValue': 123.0,
                'isNull': True|False,
                'longValue': 123,
                'stringValue': 'string'
            },
        ],
    ]
}

Response Structure

  • (dict) --

    The response elements represent the output of a request to run a SQL statement against a database.

    • columnMetadata (list) --

      Metadata for the columns included in the results.

      • (dict) --

        Contains the metadata for a column.

        • arrayBaseColumnType (integer) --

          The type of the column.

        • isAutoIncrement (boolean) --

          A value that indicates whether the column increments automatically.

        • isCaseSensitive (boolean) --

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

        • isCurrency (boolean) --

          A value that indicates whether the column contains currency values.

        • isSigned (boolean) --

          A value that indicates whether an integer column is signed.

        • label (string) --

          The label for the column.

        • name (string) --

          The name of the column.

        • 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.

        • 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.

        • type (integer) --

          The type of the column.

        • typeName (string) --

          The database-specific data type of the column.

    • generatedFields (list) --

      Values for fields generated during the request.

      <note> <p>The <code>generatedFields</code> data isn't supported by Aurora PostgreSQL. To get the values of generated fields, use the <code>RETURNING</code> clause. For more information, see <a href="https://www.postgresql.org/docs/10/dml-returning.html">Returning Data From Modified Rows</a> in the PostgreSQL documentation.</p> </note>

      • (dict) --

        Contains a value.

        Note

        This is a Tagged Union structure. Only one of the following top level keys will be set: arrayValue, blobValue, booleanValue, doubleValue, isNull, longValue, stringValue. 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'}
        • arrayValue (dict) --

          An array of values.

          Note

          This is a Tagged Union structure. Only one of the following top level keys will be set: arrayValues, booleanValues, doubleValues, longValues, stringValues. 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'}
          • arrayValues (list) --

            An array of arrays.

            • (dict) --

              Contains an array.

              Note

              This is a Tagged Union structure. Only one of the following top level keys will be set: arrayValues, booleanValues, doubleValues, longValues, stringValues. 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'}
          • booleanValues (list) --

            An array of Boolean values.

            • (boolean) --

          • doubleValues (list) --

            An array of integers.

            • (float) --

          • longValues (list) --

            An array of floating point numbers.

            • (integer) --

          • stringValues (list) --

            An array of strings.

            • (string) --

        • blobValue (bytes) --

          A value of BLOB data type.

        • booleanValue (boolean) --

          A value of Boolean data type.

        • doubleValue (float) --

          A value of double data type.

        • isNull (boolean) --

          A NULL value.

        • longValue (integer) --

          A value of long data type.

        • stringValue (string) --

          A value of string data type.

    • numberOfRecordsUpdated (integer) --

      The number of records updated by the request.

    • records (list) --

      The records returned by the SQL statement.

      • (list) --

        • (dict) --

          Contains a value.

          Note

          This is a Tagged Union structure. Only one of the following top level keys will be set: arrayValue, blobValue, booleanValue, doubleValue, isNull, longValue, stringValue. 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'}
          • arrayValue (dict) --

            An array of values.

            Note

            This is a Tagged Union structure. Only one of the following top level keys will be set: arrayValues, booleanValues, doubleValues, longValues, stringValues. 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'}
            • arrayValues (list) --

              An array of arrays.

              • (dict) --

                Contains an array.

                Note

                This is a Tagged Union structure. Only one of the following top level keys will be set: arrayValues, booleanValues, doubleValues, longValues, stringValues. 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'}
            • booleanValues (list) --

              An array of Boolean values.

              • (boolean) --

            • doubleValues (list) --

              An array of integers.

              • (float) --

            • longValues (list) --

              An array of floating point numbers.

              • (integer) --

            • stringValues (list) --

              An array of strings.

              • (string) --

          • blobValue (bytes) --

            A value of BLOB data type.

          • booleanValue (boolean) --

            A value of Boolean data type.

          • doubleValue (float) --

            A value of double data type.

          • isNull (boolean) --

            A NULL value.

          • longValue (integer) --

            A value of long data type.

          • stringValue (string) --

            A value of string data type.