aiodynamo: Asyncio DynamoDB Client

24.7 · active · verified Tue Apr 14

aiodynamo is an asynchronous Python client for Amazon DynamoDB, built using asyncio. It provides a clean, Pythonic API for interacting with DynamoDB, including support for expressions, transactions, and various credential providers. The current version is 24.7, and releases occur somewhat irregularly, often monthly or quarterly, incorporating bug fixes and new features.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the aiodynamo client using environment variables for AWS credentials and region, and then perform a simple operation like listing tables. Remember to install an HTTP client like `httpx` (e.g., `pip install aiodynamo[httpx]`) for the client to function.

import asyncio
import os
from aiodynamo import Client, AWSCredentials

async def main():
    # Configure AWS credentials and region via environment variables
    # or replace with your actual values.
    # AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION
    client = Client(
        region=os.environ.get("AWS_REGION", "us-east-1"),
        credentials=AWSCredentials(
            aws_access_key_id=os.environ.get("AWS_ACCESS_KEY_ID", ""),
            aws_secret_access_key=os.environ.get("AWS_SECRET_ACCESS_KEY", ""),
        )
    )
    
    print("Attempting to connect to DynamoDB...")
    try:
        # Example: List tables (requires appropriate IAM permissions)
        response = await client.list_tables()
        print(f"DynamoDB Tables: {response.table_names}")
    except Exception as e:
        print(f"Error interacting with DynamoDB: {e}")
    finally:
        await client.close()
        print("Client closed.")

if __name__ == "__main__":
    asyncio.run(main())

view raw JSON →