# AsyncIO DynamoDB
[![CircleCI](https://circleci.com/gh/HENNGE/aiodynamo.svg?style=svg)](https://circleci.com/gh/HENNGE/aiodynamo)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Documentation Status](https://readthedocs.org/projects/aiodynamo/badge/?version=latest)](https://aiodynamo.readthedocs.io/en/latest/?badge=latest)
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
```py
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
```py
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
```py
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](https://aiodynamo.readthedocs.io/)
Raw data
{
"_id": null,
"home_page": "https://github.com/HENNGE/aiodynamo",
"name": "aiodynamo",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "dynamodb, asyncio, aws",
"author": "Jonas Obrist",
"author_email": "jonas.obrist@hennge.com",
"download_url": "https://files.pythonhosted.org/packages/2a/31/c455ae437c1ed5a9e354e5aca2b616599fd0f9c36064529cecb40663a368/aiodynamo-24.7.tar.gz",
"platform": null,
"description": "# AsyncIO DynamoDB\n\n[![CircleCI](https://circleci.com/gh/HENNGE/aiodynamo.svg?style=svg)](https://circleci.com/gh/HENNGE/aiodynamo)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Documentation Status](https://readthedocs.org/projects/aiodynamo/badge/?version=latest)](https://aiodynamo.readthedocs.io/en/latest/?badge=latest)\n\nAsynchronous pythonic DynamoDB client; **2x** faster than `aiobotocore/boto3/botocore`.\n\n## Quick start\n\n### With httpx\nInstall this library\n\n`pip install \"aiodynamo[httpx]\"` or, for poetry users `poetry add aiodynamo -E httpx`\n\nConnect to DynamoDB\n\n```py\nfrom aiodynamo.client import Client\nfrom aiodynamo.credentials import Credentials\nfrom aiodynamo.http.httpx import HTTPX\nfrom httpx import AsyncClient\n\nasync def main():\n async with AsyncClient() as h:\n client = Client(HTTPX(h), Credentials.auto(), \"us-east-1\")\n```\n\n### With aiohttp\nInstall this library\n\n`pip install \"aiodynamo[aiohttp]\"` or, for poetry users `poetry add aiodynamo -E aiohttp`\n\nConnect to DynamoDB\n\n```py\nfrom aiodynamo.client import Client\nfrom aiodynamo.credentials import Credentials\nfrom aiodynamo.http.aiohttp import AIOHTTP\nfrom aiohttp import ClientSession\n\nasync def main():\n async with ClientSession() as session:\n client = Client(AIOHTTP(session), Credentials.auto(), \"us-east-1\")\n```\n\n### API use\n\n```py\nfrom aiodynamo.client import Client\nfrom aiodynamo.expressions import F\nfrom aiodynamo.models import Throughput, KeySchema, KeySpec, KeyType\n\nasync def main(client: Client):\n table = client.table(\"my-table\")\n\n # Create table if it doesn't exist\n if not await table.exists():\n await table.create(\n Throughput(read=10, write=10),\n KeySchema(hash_key=KeySpec(\"key\", KeyType.string)),\n )\n\n # Create or override an item\n await table.put_item({\"key\": \"my-item\", \"value\": 1})\n # Get an item\n item = await table.get_item({\"key\": \"my-item\"})\n print(item)\n # Update an item, if it exists.\n await table.update_item(\n {\"key\": \"my-item\"}, F(\"value\").add(1), condition=F(\"key\").exists()\n )\n```\n\n## Why aiodynamo\n\n* boto3 and botocore are synchronous. aiodynamo is built for **asynchronous** apps.\n* aiodynamo is **fast**. Two times faster than aiobotocore, botocore or boto3 for operations such as query or scan.\n* aiobotocore is very low level. aiodynamo provides a **pythonic API**, using modern Python features. For example, paginated APIs are automatically depaginated using asynchronous iterators.\n* **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.\n* **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.\n\n[Complete documentation is here](https://aiodynamo.readthedocs.io/)\n\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Asyncio DynamoDB client",
"version": "24.7",
"project_urls": {
"Documentation": "https://aiodynamo.readthedocs.io",
"Homepage": "https://github.com/HENNGE/aiodynamo",
"Repository": "https://github.com/HENNGE/aiodynamo"
},
"split_keywords": [
"dynamodb",
" asyncio",
" aws"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3566a08e633c33083fb6fe84745f5b3ab9833d356afa702e08a4136c0d615e0d",
"md5": "22431ce5b1502d7ffa93e58cda0ccb82",
"sha256": "4749855dad14e0fe96b09e2d3604582f4bad156b18da90f9612260fd06523913"
},
"downloads": -1,
"filename": "aiodynamo-24.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "22431ce5b1502d7ffa93e58cda0ccb82",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 28718,
"upload_time": "2024-07-13T08:38:39",
"upload_time_iso_8601": "2024-07-13T08:38:39.141634Z",
"url": "https://files.pythonhosted.org/packages/35/66/a08e633c33083fb6fe84745f5b3ab9833d356afa702e08a4136c0d615e0d/aiodynamo-24.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2a31c455ae437c1ed5a9e354e5aca2b616599fd0f9c36064529cecb40663a368",
"md5": "ea028a8ae694540d68993e5b115dcf11",
"sha256": "6b34c1505a4aca372d60d140b9cbe7934650d1daa360e55a1e090d86af871dbb"
},
"downloads": -1,
"filename": "aiodynamo-24.7.tar.gz",
"has_sig": false,
"md5_digest": "ea028a8ae694540d68993e5b115dcf11",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 25431,
"upload_time": "2024-07-13T08:38:40",
"upload_time_iso_8601": "2024-07-13T08:38:40.674065Z",
"url": "https://files.pythonhosted.org/packages/2a/31/c455ae437c1ed5a9e354e5aca2b616599fd0f9c36064529cecb40663a368/aiodynamo-24.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-13 08:38:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "HENNGE",
"github_project": "aiodynamo",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "aiodynamo"
}