pydynox
A fast DynamoDB ORM for Python with a Rust core.
pydynox lets you work with DynamoDB using Python classes instead of raw dictionaries. The heavy lifting (serialization, deserialization) happens in Rust, so it's fast.
Key features
- Fast serialization - Rust handles the heavy lifting
- Simple API - Define models like Django or SQLAlchemy
- Type hints - Full IDE support with autocomplete
- Rate limiting - Control throughput to avoid throttling
- Lifecycle hooks - Run code before/after operations
- TTL support - Auto-delete items after expiration
- Pydantic integration - Use your existing Pydantic models
Getting started
Installation
For Pydantic support:
Define a model
A model is a Python class that maps to a DynamoDB table. You define attributes with their types, and pydynox handles the rest:
from pydynox import Model, ModelConfig
from pydynox.attributes import BooleanAttribute, NumberAttribute, StringAttribute
class User(Model):
model_config = ModelConfig(table="users")
pk = StringAttribute(hash_key=True)
sk = StringAttribute(range_key=True)
name = StringAttribute()
age = NumberAttribute(default=0)
active = BooleanAttribute(default=True)
CRUD operations
Once you have a model, you can create, read, update, and delete items:
from pydynox import Model, ModelConfig
from pydynox.attributes import NumberAttribute, StringAttribute
class User(Model):
model_config = ModelConfig(table="users")
pk = StringAttribute(hash_key=True)
sk = StringAttribute(range_key=True)
name = StringAttribute()
age = NumberAttribute(default=0)
# Create
user = User(pk="USER#123", sk="PROFILE", name="John", age=30)
user.save()
# Read
user = User.get(pk="USER#123", sk="PROFILE")
if user:
print(user.name) # John
# Update - full
user.name = "Jane"
user.save()
# Update - partial
user.update(name="Jane", age=31)
# Delete
user.delete()
That's it! You're now using DynamoDB with a clean, typed API.
What's next?
Now that you have the basics, explore these guides:
Core
| Guide | Description |
|---|---|
| Client | Configure the DynamoDB client |
| Models | Attributes, keys, defaults, and CRUD operations |
| Attributes | All available attribute types |
| Indexes | Query by non-key attributes with GSIs |
| Conditions | Filter and conditional writes |
| Atomic updates | Increment, append, and other atomic operations |
| Observability | Logging and metrics |
Operations
| Guide | Description |
|---|---|
| Async support | Async/await for high-concurrency apps |
| Batch operations | Work with multiple items at once |
| Transactions | All-or-nothing operations |
| Tables | Create and manage tables |
Features
| Guide | Description |
|---|---|
| Lifecycle hooks | Run code before/after operations |
| Rate limiting | Control throughput |
| Encryption | Field-level encryption with KMS |
| Size calculator | Calculate item sizes |
Integrations
| Guide | Description |
|---|---|
| Pydantic | Use Pydantic models |
Troubleshooting
| Guide | Description |
|---|---|
| Exceptions | Error handling |
| IAM permissions | Required AWS permissions |