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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: dynamodb_orm-0.0.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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 635a8986d6cd10887e235b02ed0a785f1f21116d45170e2eb892157b7dc56b81
MD5 444f0ea8b7238dde98eaab9de10f4f49
BLAKE2b-256 e870bd28e1de728317c5112944ecb764e056cf7f384b49b315c29905f19a9662

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