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://pydynox.readthedocs.io

License

MIT License

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.4.0.tar.gz (173.3 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.4.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.4.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.4.0-cp314-cp314-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.14macOS 10.12+ x86-64

pydynox-0.4.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.4.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.4.0-cp313-cp313-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

pydynox-0.4.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.4.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.4.0-cp312-cp312-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

pydynox-0.4.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.4.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.4.0-cp311-cp311-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pydynox-0.4.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.4.0.tar.gz.

File metadata

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

File hashes

Hashes for pydynox-0.4.0.tar.gz
Algorithm Hash digest
SHA256 778b3938b2576fa33bab1cda1fbec087383e034a199ebffca0af330154594364
MD5 c58b12bf14ecaacb61638b25581a121f
BLAKE2b-256 8f874237d96ccb846c67fd68380868e158ec621608dbfd8352b4c1f1efc0aaef

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.4.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.4.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pydynox-0.4.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f8bdec83edecd514665b4cb0681fbc847f03a58b4bfb5a5dd5f62269926e79da
MD5 3056aac5672c3895bfdb5f6776f03dd3
BLAKE2b-256 a29314482982d61372b86b8af534a0bd70a615a7b735b69bede82208c02fb0b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.4.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.4.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pydynox-0.4.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2d708c6f1bf8d06407c020080f198ad8bb8cb7d70ec5a6c64a1729c1de3a9e97
MD5 bda2c15f344c0e6ce89cb1da9fd463e4
BLAKE2b-256 759491813a0937af2691ac56d7069521e04e8ceac891272a918e468a93b63fae

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.4.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.4.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pydynox-0.4.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 38a12c60cb6d4a64a312bf9f154fd373c62f5960bc96d257a70c6ddc25a0c4eb
MD5 68bc39df56e8ce82769edd958da0fc55
BLAKE2b-256 a4d646457bf092868f6058d8c26813fb78ba55c1c82caed3fe97fa5d2c25972c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.4.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.4.0-cp314-cp314-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pydynox-0.4.0-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 53e6f9245d77740a9199dc8c81263936770702535782617f11e31b5cb6aeae09
MD5 1b861e8d80cd0c4f700bc35fc393f75b
BLAKE2b-256 39dad9d77d89d81ef6e8b6c0a592c777c205091b1c0660449e1fc80b139a3205

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.4.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.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pydynox-0.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 46ca31ddec31eecf90d995e84057fe784b08a0b92e58776f8ccebe5fa4c7e65c
MD5 9321497b924a518c7dfc90604a9f5496
BLAKE2b-256 57a667ee414e43c7a27c41f6049c2c51f705466172db8b9118e58b960f021ee0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.4.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.4.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pydynox-0.4.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 de432288a90b2ea2d374b1a54aeef8d8149e5a3aa83e658352af3c1736b4ba5e
MD5 0eee88a05247614c77addd917bb74e68
BLAKE2b-256 4ed23e1ce41b3cb48bb897fc2142a7611f64a1c7a62ae3036f2f1dd08016e406

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.4.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.4.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pydynox-0.4.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 23eddc7b69acf30575f7d8c7749f6ef803e82b808f89c61540a822eadd36c358
MD5 4a4ab375bd6c6660e748463305c9caf2
BLAKE2b-256 8f918632db251f1517db968921a7c93b65c0da408f7861e1aa49d77f1d4aec0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.4.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.4.0-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pydynox-0.4.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 bb76d273663d7e6602fc878886f3a33879aabd6c6623ec0f1f34fdd3ceaf7e00
MD5 b0d48452e309e7ebf32c231e5a3c5769
BLAKE2b-256 10f7b6f03722ec6ea90ed647aeb4656d99ea86858c4eb4799123c339d26a4d50

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.4.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.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pydynox-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 348741c872388d9aa6f2a95b0057e4211b5143d2ba57674d1fc8a4ba88b7760e
MD5 e95c7fb8ed63fa38aed51f6ea1fa41e9
BLAKE2b-256 5a0995cec0949592eedb76984c8c752359dc06e91a37ae10ad9573ae7a7fa9a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.4.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.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pydynox-0.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5891670978443390e90efacfc702085c97a32ca06789268a3ee5644704d9dc48
MD5 d0b925a1a4274eed24ae1d057b2e5371
BLAKE2b-256 94440150a01d7541cc97c80cdfc581593322a06de340b5b860d439f02672aebb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.4.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.4.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pydynox-0.4.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d3ad90e90f733e5de7637fad73866b76de9b20c4a5744bb43e6218b68d23a844
MD5 5816e63a69e14a5d267733bd284a7cc7
BLAKE2b-256 f2266803f69e1bbaaec6c8467a05d96a2c35a635ee66a295cff0a243328100f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.4.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.4.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pydynox-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2dac42b4245c1a487cbf9a6a031b6389c04c9ebb8e0ea580511071518ff49a43
MD5 fdcab9fffb336d4ad7657766205cbccd
BLAKE2b-256 efc730110c9278d48c5f6f867e635acb79ebd1906d4ab92924fc5543ac61718f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.4.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.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pydynox-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 48b784d820e2227ca068d6d7c69c87e49326e17dc90c07f89f0424e38c26ee76
MD5 e1d03a47aba41a2914314ce30212bc39
BLAKE2b-256 7fdb4fc56b6c9e18acca5123f0a29f1d1ae79e65c5b3c0abc86491c401a26134

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.4.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.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pydynox-0.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 470de5617f0b94c5b7465eb3b5adffc20c1e2f2d9ab35889eaa8640e9bf079d2
MD5 0424ff1a85ac1ca719d651589f835466
BLAKE2b-256 841746f190e493f4dc16201e0fe6303af616e782ce3e67d690eb4a65e2d20917

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.4.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.4.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pydynox-0.4.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3fe8f57322aeef7df6be78177b681ddb1348bb44902a772f372b50bf9d1dc2c4
MD5 c99a11e65c1cfc01a2de7dd44fdba87f
BLAKE2b-256 58b753e03b082508534fcba663496e99d29a9b66d411aa93eefdba57cfd5d559

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.4.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.4.0-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pydynox-0.4.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c0dd9e6c555fba6850e03494ff7fe9cdb9920eddf27b08af8fcd83eb432c791d
MD5 cbe0dbf9c29a6d607c1778c1ec10ac4d
BLAKE2b-256 be27578a7c4b3224562613169fe7db92dcac6a8546076599a097276f7ca9518f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydynox-0.4.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