Skip to main content

A fast DynamoDB ORM for Python with a Rust core

Project description

pydynox 🐍⚙️

CI PyPI version Python versions License Downloads

A fast DynamoDB ORM for Python with a Rust core.

⚠️ Alpha Software: This project is in early development. The API may change before v1.0. Use in production at your own risk. Contributions are welcome!

📋 Check the open issues to see what's planned and what's being worked on.

Why "pydynox"?

Py(thon) + Dyn(amoDB) + Ox(ide/Rust)

GenAI Contributions 🤖

This project welcomes GenAI-assisted contributions! Parts of the code and docstrings were written with AI help.

If you're using AI tools to contribute:

  • Follow the project's coding style and patterns
  • Make sure the code makes sense and is tested
  • Don't submit random or low-quality generated code
  • Review and understand what the AI generated before submitting

Features

  • Simple class-based API like PynamoDB
  • Fast serialization with Rust
  • Batch operations with auto-splitting
  • Transactions
  • Global Secondary Indexes
  • Async support
  • Pydantic integration

Installation

pip install pydynox

For Pydantic support:

pip install pydynox[pydantic]

Quick Start

Define a Model

from pydynox import Model, String, Number, Boolean, List

class User(Model):
    class Meta:
        table = "users"
    
    pk = String(hash_key=True)
    sk = String(range_key=True)
    name = String()
    email = String()
    age = Number(default=0)
    active = Boolean(default=True)
    tags = List(String)

CRUD Operations

# Create
user = User(pk="USER#123", sk="PROFILE", name="John", email="john@test.com")
user.save()

# Read
user = User.get(pk="USER#123", sk="PROFILE")

# Update
user.name = "John Doe"
user.save()

# Delete
user.delete()

Query

from pydynox import Condition

# Simple query
users = User.query(pk="USER#123")

# With filters
users = User.query(pk="USER#123") \
    .where(Condition.begins_with("sk", "ORDER#")) \
    .where(Condition.gt("age", 18)) \
    .exec()

# Iterate (auto pagination)
for user in users:
    print(user.name)

Conditions

from pydynox import Condition

# Save with condition
user.save(condition=Condition.not_exists("pk"))

# Delete with condition
user.delete(condition=Condition.eq("version", 5))

# Combine conditions
user.save(
    condition=Condition.not_exists("pk") | Condition.eq("version", 1)
)

Available conditions:

  • Condition.eq(field, value) - equals
  • Condition.ne(field, value) - not equals
  • Condition.gt(field, value) - greater than
  • Condition.gte(field, value) - greater than or equal
  • Condition.lt(field, value) - less than
  • Condition.lte(field, value) - less than or equal
  • Condition.exists(field) - attribute exists
  • Condition.not_exists(field) - attribute does not exist
  • Condition.begins_with(field, prefix) - string starts with
  • Condition.contains(field, value) - string or list contains
  • Condition.between(field, low, high) - value in range

Atomic Updates

from pydynox import Action

# Simple set
user.update(name="New Name", email="new@test.com")

# Increment a number
user.update(Action.increment("age", 1))

# Append to list
user.update(Action.append("tags", ["verified"]))

# Remove field
user.update(Action.remove("temp_field"))

# Combine with condition
user.update(
    Action.increment("age", 1),
    condition=Condition.eq("status", "active")
)

Batch Operations

# Batch write
with User.batch_write() as batch:
    batch.save(user1)
    batch.save(user2)
    batch.delete(user3)

# Batch get
users = User.batch_get([
    ("USER#1", "PROFILE"),
    ("USER#2", "PROFILE"),
])

Global Secondary Index

from pydynox import GlobalIndex

class User(Model):
    class Meta:
        table = "users"
    
    pk = String(hash_key=True)
    sk = String(range_key=True)
    email = String()
    
    email_index = GlobalIndex(hash_key="email")

# Query on index
users = User.email_index.query(email="john@test.com")

Transactions

with User.transaction() as tx:
    tx.save(user1)
    tx.delete(user2)
    tx.update(user3, Action.increment("age", 1))

Async Support

# All methods work with await
user = await User.get(pk="USER#123", sk="PROFILE")
await user.save()

async for user in User.query(pk="USER#123"):
    print(user.name)

Pydantic Integration

from pydynox import dynamodb_model
from pydantic import BaseModel, EmailStr

@dynamodb_model(table="users", hash_key="pk", range_key="sk")
class User(BaseModel):
    pk: str
    sk: str
    name: str
    email: EmailStr
    age: int = 0

# All pydynox methods available
user = User(pk="USER#123", sk="PROFILE", name="John", email="john@test.com")
user.save()

Table Management

# Create table
User.create_table()

# Create with custom capacity
User.create_table(read_capacity=10, write_capacity=5)

# Create with on-demand billing
User.create_table(billing_mode="PAY_PER_REQUEST")

# Check if table exists
if not User.table_exists():
    User.create_table()

# Delete table
User.delete_table()

Documentation

Full documentation: https://leandrodamascena.github.io/pydynox

License

MIT License

Inspirations

This project was inspired by:

  • PynamoDB - The ORM-style API and model design
  • Pydantic - Data validation patterns and integration approach
  • dynarust - Rust DynamoDB client patterns
  • dyntastic - Pydantic + DynamoDB integration ideas

Building from Source

Requirements

  • Python 3.11+
  • Rust 1.70+
  • maturin

Setup

# Clone the repo
git clone https://github.com/leandrodamascena/pydynox.git
cd pydynox

# Install maturin
pip install maturin

# Build and install locally
maturin develop

# Or with uv
uv run maturin develop

Running Tests

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

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

pydynox-0.5.0.tar.gz (194.4 kB view details)

Uploaded Source

Built Distributions

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

pydynox-0.5.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

pydynox-0.5.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64

pydynox-0.5.0-cp314-cp314-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pydynox-0.5.0-cp314-cp314-macosx_10_12_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

pydynox-0.5.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pydynox-0.5.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

pydynox-0.5.0-cp313-cp313-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pydynox-0.5.0-cp313-cp313-macosx_10_12_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

pydynox-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pydynox-0.5.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

pydynox-0.5.0-cp312-cp312-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pydynox-0.5.0-cp312-cp312-macosx_10_12_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

pydynox-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pydynox-0.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

pydynox-0.5.0-cp311-cp311-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pydynox-0.5.0-cp311-cp311-macosx_10_12_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

File details

Details for the file pydynox-0.5.0.tar.gz.

File metadata

  • Download URL: pydynox-0.5.0.tar.gz
  • Upload date:
  • Size: 194.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pydynox-0.5.0.tar.gz
Algorithm Hash digest
SHA256 928da38394018368efb159953fc2108621daba4695a2ec95890f45f376042463
MD5 30eadfcbf238d9901614e16ae4465c30
BLAKE2b-256 2200bbe634522da23817b6a0c935e348e51e88d69a5c5540a04979dfda5c0b53

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.5.0.tar.gz:

Publisher: release.yml on leandrodamascena/pydynox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydynox-0.5.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pydynox-0.5.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 97f0bd5ddff444e966e1b68a809b04128e8e2d387e7b6e856daa689aeaf1347d
MD5 c937bd7a2528d4fedab82d2ffd1f1134
BLAKE2b-256 5f718c311c005198b175133cec1cb3f8d9f9d0eb1f39efbe314cf61e81304d48

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.5.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on leandrodamascena/pydynox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydynox-0.5.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pydynox-0.5.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 746c15126514d284528b13f87a8b838be04247df023a7aedfa437a9dbfcaceff
MD5 357d9dc9c97932eb1d59ff455fcf2be9
BLAKE2b-256 3089758fd1c3e9b47f00c6252c92e72a0b88ab8d207d544a1434927a6a09126e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.5.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on leandrodamascena/pydynox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydynox-0.5.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pydynox-0.5.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bebb4e7009d76391033600d42e905e2ea1eae74696453a33f8af91a72b3844e8
MD5 4ac05ef6c369211b946f671a03a41aa7
BLAKE2b-256 6570ada74de812456b207929ac7b68136473ab669242cc082e39691d771a34e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.5.0-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: release.yml on leandrodamascena/pydynox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydynox-0.5.0-cp314-cp314-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pydynox-0.5.0-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 134a49567d3d7d78e7a7c819e7e52730a05c560eb34fff30fee6778c8b248c3c
MD5 998f1300a772b1c2dcf10d6bb7534297
BLAKE2b-256 91ee8a05d414af16ecdcbb90d41577074fcb9fb96f0b9dbb6949f781fb7e6771

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.5.0-cp314-cp314-macosx_10_12_x86_64.whl:

Publisher: release.yml on leandrodamascena/pydynox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydynox-0.5.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pydynox-0.5.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fb080dd75ab3ac12f23995eb8191f2b47a9d87b5b8604982b972878488690299
MD5 09fc5a54ca53ac2ab597476f5a58b1f9
BLAKE2b-256 9d85c94195b8529eace871e940478603129f032de392f054548d383f62caa1b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.5.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on leandrodamascena/pydynox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydynox-0.5.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pydynox-0.5.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7dbff30e3c0236d13ad63b5544eba68bec2fdca294744b9a9fdb59f2b682d1ed
MD5 fd8043b7b5d96983885888546d8eac9b
BLAKE2b-256 d5396c6c7b971abe2216a4e9b9b156893396963921d16976cdf0ce96bad6109c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.5.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on leandrodamascena/pydynox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydynox-0.5.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pydynox-0.5.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e35d1873d2c996880cdcfc4d946e7050e46c21ffed60f853ef43def032402ac3
MD5 b7655d1885dd8e2cce6f067199916e81
BLAKE2b-256 e648440609f3efe9582b8725c87f3ccd5381c6885e507cddd77846757b936d14

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.5.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on leandrodamascena/pydynox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydynox-0.5.0-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pydynox-0.5.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7b98e51a6956c431eb436ade8fc021feab03511e4d9170ef3ac7c052c12d7877
MD5 28af282afe25fa128e93015728dbfd76
BLAKE2b-256 b867ba8de96ac39c3e164c34380dd3f9353b672c0014e70f8774b029b542a750

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.5.0-cp313-cp313-macosx_10_12_x86_64.whl:

Publisher: release.yml on leandrodamascena/pydynox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydynox-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pydynox-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 45edd30cc18103f023776e3bec486e21091d1a4c65c386362c6a49e3213fdf03
MD5 3dc793b1b320b5f966ccdfa706f9e949
BLAKE2b-256 86f052310687ca85a5359d80a044bb639fc17ff77ae3d3b00482197ffeb6a2ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on leandrodamascena/pydynox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydynox-0.5.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pydynox-0.5.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dda6e3d366b488a4463b61565b4708d17c45741db7a12295d93e4faf76ac8365
MD5 8afce4bfae853dbf968af00def1582ce
BLAKE2b-256 4e16289aca9aeab04d76b11d4595148849309a18a28838505715f7f0924363b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.5.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on leandrodamascena/pydynox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydynox-0.5.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pydynox-0.5.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e79fb40c3462110b7e5acc6f4567a500c8a1dec2e5367d7002a35834d40d21df
MD5 164ee7ae91ebff89999ac2f8397677af
BLAKE2b-256 b55f1b1d66be51371e57e8ace33554d37fad4c37ea347f514596cdd2a8fa8e6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.5.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on leandrodamascena/pydynox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydynox-0.5.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pydynox-0.5.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 414afdb481a574fa1cbea62071d11f7fba4937d6017792d739a620a2084fb2ac
MD5 47f812f2442094ae4b6dbcdfe3ccb3d7
BLAKE2b-256 2b0e888079e442f5c93178c991fa445b14b3c2da0b791818c5999bf547d0ec82

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.5.0-cp312-cp312-macosx_10_12_x86_64.whl:

Publisher: release.yml on leandrodamascena/pydynox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydynox-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pydynox-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f30d180a46d4b03a37a03c60faafdfdb9879263b5f73027d7bedbed2006e0666
MD5 bac6f476095a6093419a53311a23ecee
BLAKE2b-256 3fc6acf80a6b0293f2b5dbab98ffaaf03b587775ccd0cf28f803aa628fd5ae6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on leandrodamascena/pydynox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydynox-0.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pydynox-0.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dc8da8a5978e52afacc0dcd99dc6fda49dfef6fbf4d4183d94a02381f35b4690
MD5 af58d4817e36e8b174665a429c1202a5
BLAKE2b-256 cee48685366a7162a94c7882128d05ed6e156aacff34147989744da4324ee502

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on leandrodamascena/pydynox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydynox-0.5.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pydynox-0.5.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2d9f07585279e56b7b091249ad0d2ab78c392a678959c507a33bb2228fb7070c
MD5 c7ae83234035ab257ba707ef8097d9c0
BLAKE2b-256 3f7a721d3a3546869205c5c6a0f38c23e125bce411146a6effb312c9658e13b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.5.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on leandrodamascena/pydynox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydynox-0.5.0-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pydynox-0.5.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b9d03f8952587b9ddedb53ccd8052020611cc175f297b5ad985dfe2a8ea21352
MD5 90901efe47ac4f0813c6bfdde462e3e1
BLAKE2b-256 2f42e5f27d42b884e3e7f51def25086c2697d71effa187332abb0d40c3539585

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.5.0-cp311-cp311-macosx_10_12_x86_64.whl:

Publisher: release.yml on leandrodamascena/pydynox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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