mypy-boto3-rds-data Type Annotations

1.42.3 · active · verified Sat Apr 11

mypy-boto3-rds-data provides comprehensive type annotations for the boto3 RDSDataService, enhancing static analysis, autocompletion, and type checking for AWS RDS Data API interactions in Python. This library, currently at version 1.42.3, is generated by the mypy-boto3-builder and offers compatibility with popular IDEs like VSCode and PyCharm, as well as type checkers such as Mypy and Pyright. New versions are released in sync with boto3 updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a type-hinted RDS Data Service client and use it to execute an SQL statement. The `TYPE_CHECKING` block ensures type hints are only active during static analysis, avoiding runtime dependency on mypy-boto3-rds-data for production code.

import boto3
from typing import TYPE_CHECKING
from mypy_boto3_rds_data.client import RDSDataServiceClient


# Ensure boto3 is installed: pip install boto3 mypy-boto3-rds-data

def get_rds_data_client() -> RDSDataServiceClient:
    if TYPE_CHECKING:
        client: RDSDataServiceClient = boto3.client("rds-data")
    else:
        client = boto3.client("rds-data")
    return client


def execute_statement(sql: str, database: str, resource_arn: str, secret_arn: str) -> None:
    client = get_rds_data_client()
    
    # Example: Execute SQL statement
    response = client.execute_statement(
        sql=sql,
        database=database,
        resourceArn=resource_arn,
        secretArn=secret_arn,
        includeResultMetadata=True
    )
    print("Statement executed.")
    print(response)

# To run this, replace placeholders with actual AWS details:
# sql_query = "SELECT 1"
# db_name = "your_database_name"
# rds_resource_arn = "arn:aws:rds:region:account-id:cluster:cluster-name"
# rds_secret_arn = "arn:aws:secretsmanager:region:account-id:secret:secret-name"
# execute_statement(sql_query, db_name, rds_resource_arn, rds_secret_arn)

view raw JSON →