Registry / aws / dyntastic

dyntastic

JSON →
library0.18.0pypypi✓ verified 85d ago

Dyntastic is a Python library that provides an intuitive Object-Document Mapper (ODM) for Amazon DynamoDB, built on top of Pydantic for data validation and `boto3` for AWS interaction. It simplifies schema definition, data serialization, and common DynamoDB operations. The current version is 0.18.0, with minor releases occurring approximately every 1-2 months.

pip install dyntastic
INSTALL
IMPORT
SIG · DYNTASTIC
D
dyntastic
awspythonv0.18.0
Install
5.6s avg
Import
Disk
60MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.18.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 61MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 5.6s · import 0.000s · 61MB
60MB installed
● package 60MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Dyntastic
from dyntastic import Dyntastic
from dyntastic import DyntasticModel
Attr
from dyntastic import Attr
Index
from dyntastic import Index

This quickstart demonstrates how to define a DyntasticModel, save, retrieve, update, and delete items. It assumes DynamoDB is available at the configured region/host. The `__table_name__` and `__table_hash_key__` define the DynamoDB table structure. `table_create_args` in `Config` can be used to specify creation parameters like `BillingMode`.

import os from dyntastic import DyntasticModel # Set environment variable for DynamoDB region (or explicitly define __table_region__) # For local development, you might set DYNTASTIC_HOST='http://localhost:8000' os.environ['DYNTASTIC_REGION'] = os.environ.get('DYNTASTIC_REGION', 'us-east-1') class User(DyntasticModel): __table_name__ = "DyntasticExampleUsers" __table_hash_key__ = "user_id" user_id: str name: str email: str age: int = 0 class Config: table_create_args = { "BillingMode": "PAY_PER_REQUEST" } # Create table if it doesn't exist (optional, auto-creates on first write by default) # User.create_table() # Create a new user user_data = {"user_id": "user123", "name": "Alice", "email": "alice@example.com", "age": 30} alice = User(**user_data) alice.save() # This will create the table if it doesn't exist print(f"Saved user: {alice}") # Retrieve a user by their hash key retrieved_user = User.get("user123") print(f"Retrieved user: {retrieved_user}") # Update user if retrieved_user: retrieved_user.age = 31 retrieved_user.save() print(f"Updated user age: {retrieved_user.age}") # Delete user if retrieved_user: retrieved_user.delete() print(f"Deleted user: {retrieved_user.user_id}") # Clean up (optional: delete table) # User.delete_table()
Debug
Known issues
breakingDyntastic versions prior to 0.13.1 had limited or no compatibility with Pydantic V2. If you are using Pydantic V2 (released with Pydantic 2.0+), you must upgrade Dyntastic to version 0.13.1 or newer.
fix
Ensure `dyntastic>=0.13.1` is installed if your project uses `pydantic>=2.0`. Verify your Pydantic version with `pip show pydantic`.
affects: <0.13.1
gotchaPrior to version 0.11.0, the `transaction()` context manager would attempt to commit batch operations even if an exception was raised during its `__exit__`. This behavior was changed in 0.11.0 to prevent commits when an exception occurs.
fix
Upgrade to `dyntastic>=0.11.0` if you rely on transactions not committing on error. Review existing transaction error handling in older versions.
affects: <0.11.0
gotchaDyntastic versions prior to 0.17.0 had issues correctly handling field aliases, specifically causing problems with deleting items from tables where the hash key was defined using an alias.
fix
Upgrade to `dyntastic>=0.17.0` to ensure correct handling of aliased keys in all operations, including deletion.
affects: <0.17.0
gotchaFor Dyntastic models, the `__table_region__` and `__table_host__` attributes can be implicitly set via `DYNTASTIC_REGION` and `DYNTASTIC_HOST` environment variables, respectively. This feature was introduced in version 0.14.0.
fix
If using `dyntastic<0.14.0`, you must explicitly define `__table_region__` and `__table_host__` on your `DyntasticModel` classes, or configure `boto3` directly. For `dyntastic>=0.14.0`, setting the environment variables is an option.
affects: <0.14.0
Upgrade
Version history
0.18.0latest on PyPI · released Apr 6, 2025
Audit
Dependencies
pydanticrequiredCore data validation and serialization. Pydantic v2+ requires dyntastic >= 0.13.1.
boto3requiredAWS SDK for Python, used for interacting with DynamoDB.
Agent activity
24 hits · last 30 days
node
22
Resources
dyntastic — pip install dyntastic · libregistry