:doc:`AgentsforBedrockRuntime <../../bedrock-agent-runtime>` / Client / generate_query

**************
generate_query
**************



.. py:method:: AgentsforBedrockRuntime.Client.generate_query(**kwargs)

  

  Generates an SQL query from a natural language query. For more information, see `Generate a query for structured data <https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-generate-query.html>`__ in the Amazon Bedrock User Guide.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/bedrock-agent-runtime-2023-07-26/GenerateQuery>`_  


  **Request Syntax**
  ::

    response = client.generate_query(
        queryGenerationInput={
            'text': 'string',
            'type': 'TEXT'
        },
        transformationConfiguration={
            'mode': 'TEXT_TO_SQL',
            'textToSqlConfiguration': {
                'knowledgeBaseConfiguration': {
                    'knowledgeBaseArn': 'string'
                },
                'type': 'KNOWLEDGE_BASE'
            }
        }
    )
    
  :type queryGenerationInput: dict
  :param queryGenerationInput: **[REQUIRED]** 

    Specifies information about a natural language query to transform into SQL.

    

  
    - **text** *(string) --* **[REQUIRED]** 

      The text of the query.

      

    
    - **type** *(string) --* **[REQUIRED]** 

      The type of the query.

      

    
  
  :type transformationConfiguration: dict
  :param transformationConfiguration: **[REQUIRED]** 

    Specifies configurations for transforming the natural language query into SQL.

    

  
    - **mode** *(string) --* **[REQUIRED]** 

      The mode of the transformation.

      

    
    - **textToSqlConfiguration** *(dict) --* 

      Specifies configurations for transforming text to SQL.

      

    
      - **knowledgeBaseConfiguration** *(dict) --* 

        Specifies configurations for a knowledge base to use in transformation.

        

      
        - **knowledgeBaseArn** *(string) --* **[REQUIRED]** 

          The ARN of the knowledge base

          

        
      
      - **type** *(string) --* **[REQUIRED]** 

        The type of resource to use in transformation.

        

      
    
  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'queries': [
              {
                  'sql': 'string',
                  'type': 'REDSHIFT_SQL'
              },
          ]
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **queries** *(list) --* 

        A list of objects, each of which defines a generated query that can correspond to the natural language queries.

        
        

        - *(dict) --* 

          Contains information about a query generated for a natural language query.

          
          

          - **sql** *(string) --* 

            An SQL query that corresponds to the natural language query.

            
          

          - **type** *(string) --* 

            The type of transformed query.

            
      
    
  
  **Exceptions**
  
  *   :py:class:`AgentsforBedrockRuntime.Client.exceptions.ResourceNotFoundException`

  
  *   :py:class:`AgentsforBedrockRuntime.Client.exceptions.ConflictException`

  
  *   :py:class:`AgentsforBedrockRuntime.Client.exceptions.ValidationException`

  
  *   :py:class:`AgentsforBedrockRuntime.Client.exceptions.InternalServerException`

  
  *   :py:class:`AgentsforBedrockRuntime.Client.exceptions.DependencyFailedException`

  
  *   :py:class:`AgentsforBedrockRuntime.Client.exceptions.BadGatewayException`

  
  *   :py:class:`AgentsforBedrockRuntime.Client.exceptions.ThrottlingException`

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

  
  *   :py:class:`AgentsforBedrockRuntime.Client.exceptions.ServiceQuotaExceededException`

  