aurora-data-api

raw JSON →
0.5.0 verified Fri May 01 auth: no python

A Python DB-API 2.0 client for the AWS Aurora Serverless Data API. Version 0.5.0 adds compatibility with RDS Data API for Aurora Serverless v2. The library provides a familiar database interface (PEP 249) for accessing Aurora Serverless databases without persistent connections.

pip install aurora-data-api
error TypeError: 'list' object has no attribute 'items'
cause Passing a list as a parameter value (e.g., cursor.execute('SELECT * FROM t WHERE id IN (%s)', [1,2])). The driver does not support array parameters.
fix
Use tuple expansion or loop: cursor.execute('SELECT * FROM t WHERE id IN (%s,%s)', (1,2))
error botocore.errorfactory.BadRequestException: An error occurred (BadRequestException) when calling the ExecuteStatement operation: Invalid secret arn
cause The secret ARN is malformed or the secret does not exist.
fix
Verify the secret ARN format: arn:aws:secretsmanager:<region>:<account>:secret:<name>-<random>
breaking Version 0.4.0 reverted native type casting for JSON and UUID columns; they are now returned as strings. If you relied on automatic conversion, update your code.
fix Manually parse JSON or UUID fields from strings.
gotcha Array parameters are not supported and raise an error (since 0.4.0). Use individual parameters or batch execute.
fix Pass parameters as scalar values, not lists.
deprecated The `resource_arn` parameter is used but AWS documentation now calls it `resource_arn`; older aliases may be removed.
fix Use `resource_arn` as the parameter name.

Connect and query Aurora Serverless via Data API

import aurora_data_api

cluster_arn = 'arn:aws:rds:us-east-1:123456789012:cluster:my-cluster'
secret_arn = 'arn:aws:secretsmanager:us-east-1:123456789012:secret:my-secret'
database = 'mydb'

connection = aurora_data_api.connect(
    database=database,
    secret_arn=secret_arn,
    resource_arn=cluster_arn
)

with connection.cursor() as cursor:
    cursor.execute('SELECT * FROM users')
    for row in cursor.fetchall():
        print(row)