:doc:`RDSDataService <../../rds-data>` / Client / batch_execute_statement

***********************
batch_execute_statement
***********************



.. py:method:: RDSDataService.Client.batch_execute_statement(**kwargs)

  

  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.

   

  .. note::

    

    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.

     

    There isn't a fixed upper limit on the number of parameter sets. However, the maximum size of the HTTP request submitted through the Data API is 4 MiB. If the request exceeds this limit, the Data API returns an error and doesn't process the request. This 4-MiB limit includes the size of the HTTP headers and the JSON notation in the request. Thus, the number of parameter sets that you can include depends on a combination of factors, such as the size of the SQL statement and the size of each parameter set.

     

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

    

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/rds-data-2018-08-01/BatchExecuteStatement>`_  


  **Request Syntax**
  ::

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

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

    

  
  :type secretArn: string
  :param secretArn: **[REQUIRED]** 

    The 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 <https://docs.aws.amazon.com/secretsmanager/latest/userguide/create_database_secret.html>`__.

    

  
  :type sql: string
  :param sql: **[REQUIRED]** 

    The SQL statement to run. Don't include a semicolon (;) at the end of the SQL statement.

    

  
  :type database: string
  :param database: 

    The name of the database.

    

  
  :type schema: string
  :param schema: 

    The name of the database schema.

     

    .. note::

      

      Currently, the ``schema`` parameter isn't supported.

      

    

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

          

        
        - **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: ``isNull``, ``booleanValue``, ``longValue``, ``doubleValue``, ``stringValue``, ``blobValue``, ``arrayValue``. 

        
          - **isNull** *(boolean) --* 

            A NULL value.

            

          
          - **booleanValue** *(boolean) --* 

            A value of Boolean data type.

            

          
          - **longValue** *(integer) --* 

            A value of long data type.

            

          
          - **doubleValue** *(float) --* 

            A value of double data type.

            

          
          - **stringValue** *(string) --* 

            A value of string data type.

            

          
          - **blobValue** *(bytes) --* 

            A value of BLOB data type.

            

          
          - **arrayValue** *(dict) --* 

            An array of values.

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

          
            - **booleanValues** *(list) --* 

              An array of Boolean values.

              

            
              - *(boolean) --* 

              
          
            - **longValues** *(list) --* 

              An array of integers.

              

            
              - *(integer) --* 

              
          
            - **doubleValues** *(list) --* 

              An array of floating-point numbers.

              

            
              - *(float) --* 

              
          
            - **stringValues** *(list) --* 

              An array of strings.

              

            
              - *(string) --* 

              
          
            - **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: ``booleanValues``, ``longValues``, ``doubleValues``, ``stringValues``, ``arrayValues``. 

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

          

        
      
  

  :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': [
                      {
                          'isNull': True|False,
                          'booleanValue': True|False,
                          'longValue': 123,
                          'doubleValue': 123.0,
                          'stringValue': 'string',
                          'blobValue': b'bytes',
                          'arrayValue': {
                              'booleanValues': [
                                  True|False,
                              ],
                              'longValues': [
                                  123,
                              ],
                              'doubleValues': [
                                  123.0,
                              ],
                              'stringValues': [
                                  'string',
                              ],
                              'arrayValues': [
                                  {'... recursive ...'},
                              ]
                          }
                      },
                  ]
              },
          ]
      }
      
    **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: ``isNull``, ``booleanValue``, ``longValue``, ``doubleValue``, ``stringValue``, ``blobValue``, ``arrayValue``.     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.

                
              

              - **booleanValue** *(boolean) --* 

                A value of Boolean data type.

                
              

              - **longValue** *(integer) --* 

                A value of long data type.

                
              

              - **doubleValue** *(float) --* 

                A value of double data type.

                
              

              - **stringValue** *(string) --* 

                A value of string data type.

                
              

              - **blobValue** *(bytes) --* 

                A value of BLOB data type.

                
              

              - **arrayValue** *(dict) --* 

                An array of values.

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

                - **longValues** *(list) --* 

                  An array of integers.

                  
                  

                  - *(integer) --* 
              
                

                - **doubleValues** *(list) --* 

                  An array of floating-point numbers.

                  
                  

                  - *(float) --* 
              
                

                - **stringValues** *(list) --* 

                  An array of strings.

                  
                  

                  - *(string) --* 
              
                

                - **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: ``booleanValues``, ``longValues``, ``doubleValues``, ``stringValues``, ``arrayValues``.     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'}


                  
              
            
          
        
      
    
  
  **Exceptions**
  
  *   :py:class:`RDSDataService.Client.exceptions.SecretsErrorException`

  
  *   :py:class:`RDSDataService.Client.exceptions.HttpEndpointNotEnabledException`

  
  *   :py:class:`RDSDataService.Client.exceptions.DatabaseErrorException`

  
  *   :py:class:`RDSDataService.Client.exceptions.DatabaseResumingException`

  
  *   :py:class:`RDSDataService.Client.exceptions.DatabaseUnavailableException`

  
  *   :py:class:`RDSDataService.Client.exceptions.TransactionNotFoundException`

  
  *   :py:class:`RDSDataService.Client.exceptions.InvalidSecretException`

  
  *   :py:class:`RDSDataService.Client.exceptions.InvalidResourceStateException`

  
  *   :py:class:`RDSDataService.Client.exceptions.ServiceUnavailableError`

  
  *   :py:class:`RDSDataService.Client.exceptions.ForbiddenException`

  
  *   :py:class:`RDSDataService.Client.exceptions.DatabaseNotFoundException`

  
  *   :py:class:`RDSDataService.Client.exceptions.AccessDeniedException`

  
  *   :py:class:`RDSDataService.Client.exceptions.BadRequestException`

  
  *   :py:class:`RDSDataService.Client.exceptions.StatementTimeoutException`

  
  *   :py:class:`RDSDataService.Client.exceptions.InternalServerErrorException`

  