AgentsforBedrockRuntime / Client / generate_query

generate_query#

AgentsforBedrockRuntime.Client.generate_query(**kwargs)#

Generates an SQL query from a natural language query. For more information, see Generate a query for structured data in the Amazon Bedrock User Guide.

See also: AWS API Documentation

Request Syntax

response = client.generate_query(
    queryGenerationInput={
        'text': 'string',
        'type': 'TEXT'
    },
    transformationConfiguration={
        'mode': 'TEXT_TO_SQL',
        'textToSqlConfiguration': {
            'knowledgeBaseConfiguration': {
                'knowledgeBaseArn': 'string'
            },
            'type': 'KNOWLEDGE_BASE'
        }
    }
)
Parameters:
  • queryGenerationInput (dict) –

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

  • transformationConfiguration (dict) –

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

Return type:

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