Skip to content

Examples#

Index > RDS > Examples

Auto-generated documentation for RDS type annotations stubs module mypy-boto3-rds.

Client#

Implicit type annotations#

Can be used with boto3-stubs[rds] package installed.

Write your RDS code as usual, type checking and code completion should work out of the box.

# RDSClient usage example

from boto3.session import Session


session = Session()

client = session.client("rds")  # (1)
result = client.add_role_to_db_cluster()  # (2)
  1. client: RDSClient
  2. result: EmptyResponseMetadataTypeDef
# DescribeBlueGreenDeploymentsPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("rds")  # (1)

paginator = client.get_paginator("describe_blue_green_deployments")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: RDSClient
  2. paginator: DescribeBlueGreenDeploymentsPaginator
  3. item: DescribeBlueGreenDeploymentsResponseTypeDef
# DBClusterAvailableWaiter usage example

from boto3.session import Session


session = Session()
client = session.client("rds")  # (1)

waiter = client.get_waiter("db_cluster_available")  # (2)
waiter.wait()
  1. client: RDSClient
  2. waiter: DBClusterAvailableWaiter

Explicit type annotations#

With boto3-stubs-lite[rds] or a standalone mypy_boto3_rds package, you have to explicitly specify client: RDSClient type annotation.

All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.

# RDSClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_rds.client import RDSClient
from mypy_boto3_rds.type_defs import EmptyResponseMetadataTypeDef
from mypy_boto3_rds.type_defs import AddRoleToDBClusterMessageRequestTypeDef


session = Session()

client: RDSClient = session.client("rds")

kwargs: AddRoleToDBClusterMessageRequestTypeDef = {...}
result: EmptyResponseMetadataTypeDef = client.add_role_to_db_cluster(**kwargs)
# DescribeBlueGreenDeploymentsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_rds.client import RDSClient
from mypy_boto3_rds.paginator import DescribeBlueGreenDeploymentsPaginator
from mypy_boto3_rds.type_defs import DescribeBlueGreenDeploymentsResponseTypeDef


session = Session()
client: RDSClient = session.client("rds")

paginator: DescribeBlueGreenDeploymentsPaginator = client.get_paginator("describe_blue_green_deployments")
for item in paginator.paginate(...):
    item: DescribeBlueGreenDeploymentsResponseTypeDef
    print(item)
# DBClusterAvailableWaiter usage example with type annotations

from boto3.session import Session

from mypy_boto3_rds.client import RDSClient
from mypy_boto3_rds.waiter import DBClusterAvailableWaiter

session = Session()
client: RDSClient = session.client("rds")

waiter: DBClusterAvailableWaiter = client.get_waiter("db_cluster_available")
waiter.wait()