Skip to main content

DynamoDB Not ORM

PyPI version Python License: MIT Tests

A lightweight DynamoDB ORM alternative that provides a simple way to work with DynamoDB without the complexity of a full ORM.

Features

  • Simple data model definition with dataclasses
  • Type-safe field access and updates
  • Migration system for schema changes
  • CLI tools for database operations

Installation

pip install dynamodb-not-orm

Quick Start

from dataclasses import dataclass, field
from dynamodb_not_orm import DataModel, F
from aiodynamo.models import ReturnValues


@dataclass
class UserProfile(DataModel):
    full_name: str | None = None


@dataclass
class UserDataModel(DataModel):
    __table__ = "users"
    __pk__ = "user_id"
    __sk__ = "email"

    user_id: str | None = None
    email: str | None = None
    name: str | None = None
    age: int | None = None
    profile: UserProfile | None = field(default_factory=UserProfile)


# Create a user
user = UserDataModel(user_id="123", email="user@example.com", name="John Doe", age=30)

# Get the key for DynamoDB operations
key = user.key  # {'user_id': '123', 'email': 'user@example.com'}

# Create a key for a specific user
key = UserDataModel.key("123", "user@example.com")  # {'user_id': '123', 'email': 'user@example.com'}

# create CRUD model
from dynamodb_not_orm import BaseCRUD


class UserCRUD(BaseCRUD[UserDataModel]):
    ...

user_crud = UserCRUD('eu-east-1', 'dev')
user = await user_crud.update(user.key, user.to_update_expression(), return_values=ReturnValues.all_new)
await user_crud.update(user.key, F(UserDataModel.profile.full_name).set("John Doe"))
await user_crud.update(
    user.key, F.and_(
        F(UserDataModel.age).set(18),
        F(UserDataModel.profile.full_name).set("Jane Doe"),
    )
)

CLI Usage

Initialize the migration system:

not-orm init --aws-region us-east-1 --environment dev --app-name myapp

Create a new migration:

not-orm create-empty "add user table"

Run migrations:

not-orm migrate --aws-region us-east-1 --environment dev --app-name myapp

License

MIT License

Metadata

Release files for dynamodb-not-orm 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dynamodb-not-orm 0.1.3
File Size Uploaded
dynamodb_not_orm-0.1.3.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dynamodb-not-orm 0.1.3
File Interpreter ABI Platform
dynamodb_not_orm-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 17.2 kB

Release files / dynamodb_not_orm-0.1.3.tar.gz

Download URL dynamodb_not_orm-0.1.3.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3d51e30c28f5e644b3ba9a0976cdd3f6766801d90bcd95aa0166f7e0257215c2
BLAKE2b-256 checksum
How to use checksums
6623710aa0168dd733c45056967b2996ed54af98e086fa8a088ee0e6c3439c29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / dynamodb_not_orm-0.1.3-py3-none-any.whl

Download URL dynamodb_not_orm-0.1.3-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a9b2d1238692a42545bb445faa1d20bff78a4fcd973165720f4c5edbd9b9d8b
BLAKE2b-256 checksum
How to use checksums
a9300dc65d1169d2a66ce0e939ef214e83b144ebd9798a97221fbb39688e731c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page