Skip to main content

Python ORM style interface to Amazon (AWS) DynamoDB using Schematics or Marshmallow for Schema validation

Project description

DynamoDB + Marshmallow == Dynamallow

https://img.shields.io/travis/borgstrom/dynamallow.svg https://img.shields.io/codecov/c/github/borgstrom/dynamallow.svg Latest PyPI version Number of PyPI downloads

This package is a work in progress – Feedback / Suggestions / Etc welcomed!

Two awesome things, better together!

Dynamallow is a Python library that provides integration between the Boto v3 DynamoDB API and Marshmallow. Together they provide a simple, ORM inspired, interface to the DynamoDB service with a fully defined, strongly typed schema.

from dynamallow import MarshModel
from marshmallow import fields

class Book(MarshModel):
    class Table:
        name = 'prod-books'
        hash_key = 'isbn'
        read = 25
        write = 5

    class Schema:
        isbn = fields.String(validate=validate_isbn)
        title = fields.String()
        author = fields.String()
        publisher = fields.String()
        year = fields.Number()


# Store new documents directly from dictionaries
Book.put({
    "isbn": "12345678910",
    "title": "Foo",
    "author": "Mr. Bar",
    "publisher": "Publishorama"
})

# Work with the classes as objects
# You can pass attributes from the schema to the constructor
foo = Book(isbn="12345678910", title="Foo", author="Mr. Bar",
           publisher="Publishorama")
foo.save()

# Or assign attributes
foo = Book()
foo.isbn = "12345678910"
foo.title = "Foo"
foo.author = "Mr. Bar"
foo.publisher = "Publishorama"
foo.save()

# In all cases they go through Schema validation, calls to
# .put or .save can result in ValidationError being raised.

# You can then fetch, query and scan your tables.

# Get on the hash key, and/or range key
Book.get(isbn="12345678910")

# Query based on the keys
Book.query(isbn__begins_with="12345")

# Scan based on attributes
Book.scan(author="Mr. Bar")
Book.scan(author__ne="Mr. Bar")

Documentation

Full documentation can be found online at:

http://borgstrom.github.io/dynamallow/

TODO

  • Indexes – Currently there is no support for indexes.

  • Schema Migrations

  • Partial updates on save()

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

dynamallow-0.0.2.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

dynamallow-0.0.2-py2.py3-none-any.whl (12.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file dynamallow-0.0.2.tar.gz.

File metadata

  • Download URL: dynamallow-0.0.2.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dynamallow-0.0.2.tar.gz
Algorithm Hash digest
SHA256 3eda5ea9e09134a7bffc34ce4a1288e32b1a6feafdb0d3da6549d8ba3eb8a929
MD5 8a943eb6ddda4b676a83df4625dcd440
BLAKE2b-256 d07a349c260fc6e0b977560322f10eb9e836eb2e06a9af80264fa4be76059cfd

See more details on using hashes here.

File details

Details for the file dynamallow-0.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for dynamallow-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1f178e15ca4521f72299bae1c0afdd11df54972536144cd702051c4794cab940
MD5 a9f1c30d2eb38e8bcb4780b0a3ae643c
BLAKE2b-256 eb505265c707bfc4f4ea9b4ff0bc80578f9f23e2c6e9b347d3e8297e33b7e706

See more details on using hashes here.

Supported by

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