Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Installation

pip install aurora-data-api

For async support using aiobotocore::

pip install aurora-data-api[async]

Prerequisites
-------------
* Set up an AWS
Expand Down Expand Up @@ -66,6 +70,19 @@ the standard main entry point, and accepts two implementation-specific keyword a
cursor.execute("select * from pg_catalog.pg_tables")
print(cursor.fetchall())

For async usage (requires ``aurora-data-api[async]``)::

.. code-block:: python

import aurora_data_api.async_ as aurora_data_api_async

cluster_arn = "arn:aws:rds:us-east-1:123456789012:cluster:my-aurora-serverless-cluster"
secret_arn = "arn:aws:secretsmanager:us-east-1:123456789012:secret:rds-db-credentials/MY_DB"
async with await aurora_data_api_async.connect(aurora_cluster_arn=cluster_arn, secret_arn=secret_arn, database="my_db") as conn:
async with await conn.cursor() as cursor:
await cursor.execute("select * from pg_catalog.pg_tables")
print(await cursor.fetchall())

The cursor supports iteration (and automatically wraps the query in a server-side cursor and paginates it if required):

.. code-block:: python
Expand All @@ -74,6 +91,15 @@ The cursor supports iteration (and automatically wraps the query in a server-sid
for row in cursor.execute("select * from pg_catalog.pg_tables"):
print(row)

For async iteration::

.. code-block:: python

async with await conn.cursor() as cursor:
await cursor.execute("select * from pg_catalog.pg_tables")
async for row in cursor:
print(row)

Motivation
----------
The `RDS Data API <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html>`_ is the link between the
Expand Down
Loading
Loading