Skip to main content

Asyncio DynamoDB client

Project description

AsyncIO DynamoDB

CircleCI Code style: black Documentation Status

Asynchronous pythonic DynamoDB client; 2x faster than aiobotocore/boto3/botocore.

Quick start

With httpx

Install this library

pip install "aiodynamo[httpx]" or, for poetry users poetry add aiodynamo -E httpx

Connect to DynamoDB

from aiodynamo.client import Client
from aiodynamo.credentials import Credentials
from aiodynamo.http.httpx import HTTPX
from httpx import AsyncClient

async def main():
    async with AsyncClient() as h:
        client = Client(HTTPX(h), Credentials.auto(), "us-east-1")

With aiohttp

Install this library

pip install "aiodynamo[aiohttp]" or, for poetry users poetry add aiodynamo -E aiohttp

Connect to DynamoDB

from aiodynamo.client import Client
from aiodynamo.credentials import Credentials
from aiodynamo.http.aiohttp import AIOHTTP
from aiohttp import ClientSession

async def main():
    async with ClientSession() as session:
        client = Client(AIOHTTP(session), Credentials.auto(), "us-east-1")

API use

from aiodynamo.client import Client
from aiodynamo.expressions import F
from aiodynamo.models import Throughput, KeySchema, KeySpec, KeyType

async def main(client: Client):
    table = client.table("my-table")

    # Create table if it doesn't exist
    if not await table.exists():
        await table.create(
            Throughput(read=10, write=10),
            KeySchema(hash_key=KeySpec("key", KeyType.string)),
        )

    # Create or override an item
    await table.put_item({"key": "my-item", "value": 1})
    # Get an item
    item = await table.get_item({"key": "my-item"})
    print(item)
    # Update an item, if it exists.
    await table.update_item(
        {"key": "my-item"}, F("value").add(1), condition=F("key").exists()
    )

Why aiodynamo

  • boto3 and botocore are synchronous. aiodynamo is built for asynchronous apps.
  • aiodynamo is fast. Two times faster than aiobotocore, botocore or boto3 for operations such as query or scan.
  • aiobotocore is very low level. aiodynamo provides a pythonic API, using modern Python features. For example, paginated APIs are automatically depaginated using asynchronous iterators.
  • Legible source code. botocore and derived libraries generate their interface at runtime, so it cannot be inspected and isn't typed. aiodynamo is hand written code you can read, inspect and understand.
  • Pluggable HTTP client. If you're already using an asynchronous HTTP client in your project, you can use it with aiodynamo and don't need to add extra dependencies or run into dependency resolution issues.

Complete documentation is here

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiodynamo-24.7.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

aiodynamo-24.7-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

Details for the file aiodynamo-24.7.tar.gz.

File metadata

  • Download URL: aiodynamo-24.7.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for aiodynamo-24.7.tar.gz
Algorithm Hash digest
SHA256 6b34c1505a4aca372d60d140b9cbe7934650d1daa360e55a1e090d86af871dbb
MD5 ea028a8ae694540d68993e5b115dcf11
BLAKE2b-256 2a31c455ae437c1ed5a9e354e5aca2b616599fd0f9c36064529cecb40663a368

See more details on using hashes here.

File details

Details for the file aiodynamo-24.7-py3-none-any.whl.

File metadata

  • Download URL: aiodynamo-24.7-py3-none-any.whl
  • Upload date:
  • Size: 28.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for aiodynamo-24.7-py3-none-any.whl
Algorithm Hash digest
SHA256 4749855dad14e0fe96b09e2d3604582f4bad156b18da90f9612260fd06523913
MD5 22431ce5b1502d7ffa93e58cda0ccb82
BLAKE2b-256 3566a08e633c33083fb6fe84745f5b3ab9833d356afa702e08a4136c0d615e0d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page