Skip to main content

A simple ORM-like interface for DynamoDB using Pydantic models

Project description

Python DynamoDB ORM

A lightweight and type-safe wrapper for AWS DynamoDB with Pydantic integration.

Features

  • Type-safe DynamoDB operations using Pydantic models
  • Support for CRUD operations (Create, Read, Update, Delete)
  • Query filtering and conditional operations
  • Clean and intuitive API design
  • Comprehensive error handling

Installation

git clone https://github.com/leehjhjhj/dynamodb-model
uv sync

Quick Start

from pydantic import BaseModel, Field
from datetime import datetime
from typing import Optional

# Define your model
class UserModel(BaseModel):
    user_id: str = Field(alias='partition_key')
    email: str = Field(alias='sort_key')
    name: str
    age: int
    created_at: datetime = Field(default_factory=datetime.now)
    updated_at: Optional[datetime] = None

# Initialize DynamoDB wrapper
user_db = DynamoDBModel[UserModel](
    table_name='users',
    model_class=UserModel
)

# Create a new user
new_user = UserModel(
    user_id="user123",
    email="user@example.com",
    name="John Doe",
    age=30
)
user_db.put(new_user)

# Get user
user = user_db.get("user123", "user@example.com")

# Query users
users = user_db.query(
    partition_key="user123",
    sort_key_condition={
        "operator": "begins_with",
        "value": "user"
    }
)

Requirements

  • Python 3.7+
  • boto3
  • pydantic

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

dynamodb_orm-0.2.0.tar.gz (79.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dynamodb_orm-0.2.0-py3-none-any.whl (1.9 kB view details)

Uploaded Python 3

File details

Details for the file dynamodb_orm-0.2.0.tar.gz.

File metadata

  • Download URL: dynamodb_orm-0.2.0.tar.gz
  • Upload date:
  • Size: 79.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for dynamodb_orm-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bea8dc014d210dd1a18b4645d224ae7d92401d144b0c265a8e9e55d6594d94d2
MD5 28b5a1b2c0e423ab39e2a3cdb3025b9f
BLAKE2b-256 f36ee0e7f7e58bd7a8fad5d76f11d8f5895807ad2d49adbe825bb8ee352b5c73

See more details on using hashes here.

File details

Details for the file dynamodb_orm-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dynamodb_orm-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 1.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for dynamodb_orm-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0f84e75659dde79cad85b93c3c869771013c67d8dad35a0423acf275aae85e3
MD5 e1f2f292194dc88fd4e8dfea500552ae
BLAKE2b-256 3091cdc4fc7a7382f66a299555a69cc5c806c1862d95488632edd6bfe053e2ae

See more details on using hashes here.

Supported by

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