Python ORM style interface to Amazon (AWS) DynamoDB using Marshmallow for Schema validation
Project description
DynamoDB + Marshmallow == Dynamallow
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 / Scan based on attributes
Book.query(author="Mr. Bar")
Book.query(author__ne="Mr. Bar")
Documentation
Full documentation can be found online at:
TODO
Indexes – Currently there is no support for indexes.
Schema Migrations
Partial updates on save()
Project details
Release history Release notifications | RSS feed
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.1.tar.gz
(8.2 kB
view hashes)
Built Distribution
Close
Hashes for dynamallow-0.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86482b1bf4310d0a2bf9d40c931d565116cac13ac563b67c88d4c18005d70c7b |
|
MD5 | eb27c01499e7a662294d211342b071fe |
|
BLAKE2b-256 | 883462b7c68600998b0b9814265760d7f0369bb9a1507af43bdde72a38713750 |