mypy-boto3-dsql Type Annotations
This package provides machine-generated type annotations for the `boto3` AuroraDSQL service, specifically for `boto3` version 1.42.3. It's part of the `mypy-boto3-builder` ecosystem, designed to bring robust static type checking to `boto3` usage with `mypy`. The project maintains a frequent release cadence, often aligning with new `boto3` versions.
Warnings
- breaking The `mypy-boto3-builder` (which generates these stubs) dropped support for Python 3.8 in version 8.12.0. Projects using Python 3.8 will need to upgrade to Python 3.9+ to use newer versions of these stubs.
- breaking Version 8.9.0 of the builder introduced breaking changes to `TypeDef` naming conventions, specifically for packed method arguments and conflicting names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`).
- gotcha These packages provide only type stubs and do not include the `boto3` runtime. `boto3` must be installed separately for your application to function.
- gotcha For optimal type-checking accuracy, the `mypy-boto3-dsql` package version should ideally match the `boto3` version installed. Mismatched versions can lead to `mypy` errors if there are API differences between the `boto3` runtime and the stub files.
- gotcha AWS services can be deprecated, renamed, or have their APIs significantly altered. This can lead to `mypy-boto3` stubs for those services being removed or requiring different package names (e.g., `sms-voice` was replaced by `pinpoint-sms-voice`).
Install
-
pip install mypy-boto3-dsql -
pip install boto3 mypy
Imports
- DSQLClient
from mypy_boto3_dsql.client import DSQLClient
- ExecuteStatementRequestRequestTypeDef
from mypy_boto3_dsql.type_defs import ExecuteStatementRequestRequestTypeDef
- ExecuteStatementResponseTypeDef
from mypy_boto3_dsql.type_defs import ExecuteStatementResponseTypeDef
Quickstart
import boto3
from mypy_boto3_dsql.client import DSQLClient
from mypy_boto3_dsql.type_defs import ExecuteStatementRequestRequestTypeDef, ExecuteStatementResponseTypeDef
import os
# Configure AWS credentials and region via environment variables or ~/.aws/credentials
# For example, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION
def main():
try:
# mypy-boto3 stubs ensure type-hinting for boto3 clients
client: DSQLClient = boto3.client("dsql", region_name=os.environ.get('AWS_REGION', 'us-east-1'))
# Example request (adjust parameters as needed for your DSQL setup)
request_params: ExecuteStatementRequestRequestTypeDef = {
"dbClusterIdentifier": "your-db-cluster-identifier",
"database": "your-database-name",
"sql": "SELECT 1",
"schema": "public",
"continueAfterTimeout": False,
"transactionIdentifier": "",
"formatRecords": True
}
print("Executing DSQL statement...")
response: ExecuteStatementResponseTypeDef = client.execute_statement(**request_params)
print("Statement executed successfully!")
print(f"Response Status: {response.get('responseMetadata', {}).get('HTTPStatusCode')}")
if 'records' in response:
print("Records returned:", response['records'])
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == "__main__":
# Set dummy values if env vars are not present for demonstration purposes.
# In a real scenario, these should be properly configured.
os.environ.setdefault('AWS_ACCESS_KEY_ID', 'AKIAXXXXXXXXXXXXXXXX')
os.environ.setdefault('AWS_SECRET_ACCESS_KEY', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
os.environ.setdefault('AWS_REGION', 'us-east-1')
main()