All Projects → NerdWalletOSS → Dynamorm

NerdWalletOSS / Dynamorm

Licence: other
Python object & relation mapping library for Amazon's DynamoDB service

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects

Projects that are alternatives of or similar to Dynamorm

Dynamo Easy
DynamoDB client for NodeJS and browser with a fluent api to build requests. We take care of the type mapping between JS and DynamoDB, customizable trough typescript decorators.
Stars: ✭ 133 (+84.72%)
Mutual labels:  orm, dynamodb
Npdynamodb
A Node.js Simple Query Builder and ORM for AWS DynamoDB
Stars: ✭ 113 (+56.94%)
Mutual labels:  orm, dynamodb
Dynamoid
Ruby ORM for Amazon's DynamoDB.
Stars: ✭ 449 (+523.61%)
Mutual labels:  orm, dynamodb
Flywheel
Object mapper for Amazon's DynamoDB
Stars: ✭ 124 (+72.22%)
Mutual labels:  orm, dynamodb
Dynamo Types
Typescript AWS DynamoDB ORM
Stars: ✭ 191 (+165.28%)
Mutual labels:  orm, dynamodb
Marshmallow dataclass
Automatic generation of marshmallow schemas from dataclasses.
Stars: ✭ 255 (+254.17%)
Mutual labels:  marshmallow, orm
Dynogels
DynamoDB data mapper for node.js. Originally forked from https://github.com/ryanfitz/vogels
Stars: ✭ 471 (+554.17%)
Mutual labels:  orm, dynamodb
Cakephp
CakePHP: The Rapid Development Framework for PHP - Official Repository
Stars: ✭ 8,453 (+11640.28%)
Mutual labels:  orm
Query Validator
Compile time validation for HQL and JPQL queries in Java code
Stars: ✭ 70 (-2.78%)
Mutual labels:  orm
Redis Orm
write db yaml once, generate go orm code everywhere.
Stars: ✭ 66 (-8.33%)
Mutual labels:  orm
Laravel Schematics
A Laravel package making a diagram of your models, relations and the ability to build them with it
Stars: ✭ 1,137 (+1479.17%)
Mutual labels:  schematics
Ouzo
Ouzo Framework - PHP MVC ORM
Stars: ✭ 66 (-8.33%)
Mutual labels:  orm
Aws Amplify Ecommerce
Learn how to integrate AWS Amplify and Amazon Pinpoint to create a retail website. You use the event data that's generated by customers activities on your site to send custom-tailored emails, creating a curated, omnichannel experience.
Stars: ✭ 71 (-1.39%)
Mutual labels:  dynamodb
Examples Orms
Sample uses of CockroachDB with popular ORMs
Stars: ✭ 65 (-9.72%)
Mutual labels:  orm
Ebean
Ebean ORM
Stars: ✭ 1,172 (+1527.78%)
Mutual labels:  orm
Contacts api
Serverless RESTful API with AWS Lambda, API Gateway and DynamoDB
Stars: ✭ 66 (-8.33%)
Mutual labels:  dynamodb
Foal
Elegant and all-inclusive Node.Js web framework based on TypeScript. 🚀.
Stars: ✭ 1,176 (+1533.33%)
Mutual labels:  orm
Go Dynamock
Amazon Dynamo DB Mock Driver for Golang to Test Database Interactions
Stars: ✭ 71 (-1.39%)
Mutual labels:  dynamodb
Propel2
Propel2 is an open-source high-performance Object-Relational Mapping (ORM) for modern PHP
Stars: ✭ 1,156 (+1505.56%)
Mutual labels:  orm
Dbx
A neat codegen-based database wrapper written in Go
Stars: ✭ 68 (-5.56%)
Mutual labels:  orm

DynamORM

.. image:: https://img.shields.io/travis/NerdWalletOSS/dynamorm.svg :target: https://travis-ci.org/NerdWalletOSS/dynamorm

.. image:: https://img.shields.io/codecov/c/github/NerdWalletOSS/dynamorm.svg :target: https://codecov.io/github/NerdWalletOSS/dynamorm

.. image:: https://img.shields.io/pypi/v/dynamorm.svg :target: https://pypi.python.org/pypi/dynamorm :alt: Latest PyPI version

.. image:: https://img.shields.io/pypi/pyversions/dynamorm.svg :target: https://pypi.python.org/pypi/dynamorm :alt: Supported Python Versions


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

Python + DynamoDB ♡

DynamORM (pronounced Dynamo-R-M) is a Python object & relation mapping library for Amazon's DynamoDB_ service.

The project has two goals:

  1. Abstract away the interaction with the underlying DynamoDB libraries. Python access to the DynamoDB service has evolved quickly, from Dynamo v1 in boto to Dynamo v2 in boto_ and then the new resource model in boto3_. By providing a consistent interface that will feel familiar to users of other Python ORMs (SQLAlchemy, Django, Peewee, etc) means that we can always provide best-practices for queries and take advantages of new features without needing to refactor any application logic.

  2. Delegate schema validation and serialization to more focused libraries. Building "ORM" semantics is "easy", doing data validation and serialization is not. We support both Marshmallow_ and Schematics_ for building your object schemas. You can take advantage of the full power of these libraries as they are transparently exposed in your code.

.. _DynamoDB: http://aws.amazon.com/dynamodb/ .. _Dynamo v1 in boto to Dynamo v2 in boto: http://boto.cloudhackers.com/en/latest/migrations/dynamodb_v1_to_v2.html .. _new resource model in boto3: http://boto3.readthedocs.io/en/latest/guide/dynamodb.html .. _Marshmallow: https://marshmallow.readthedocs.io/en/latest/ .. _Schematics: https://schematics.readthedocs.io/en/latest/

Supported Schema Validation Libraries

  • Schematics_ >= 2.1.0
  • Marshmallow_ >= 2.15.1

Example

.. code-block:: python

import datetime

from dynamorm import DynaModel, GlobalIndex, ProjectAll

# In this example we'll use Marshmallow, but you can also use Schematics too!
# You can see that you have to import the schema library yourself, it is not abstracted at all
from marshmallow import fields

# Our objects are defined as DynaModel classes
class Book(DynaModel):
    # Define our DynamoDB properties
    class Table:
        name = 'prod-books'
        hash_key = 'isbn'
        read = 25
        write = 5

    class ByAuthor(GlobalIndex):
        name = 'by-author'
        hash_key = 'author'
        read = 25
        write = 5
        projection = ProjectAll()

    # Define our data schema, each property here will become a property on instances of the Book class
    class Schema:
        isbn = fields.String(validate=validate_isbn)
        title = fields.String()
        author = fields.String()
        publisher = fields.String()

        # NOTE: Marshmallow uses the `missing` keyword during deserialization, which occurs when we save
        # an object to Dynamo and the attr has no value, versus the `default` keyword, which is used when
        # we load a document from Dynamo and the value doesn't exist or is null.
        year = fields.Number(missing=lambda: datetime.datetime.utcnow().year)


# 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"

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

# You can then fetch, query and scan your tables.
# Get on the hash key, and/or range key
book = Book.get(isbn="12345678910")

# Update items, with conditions
# Here our condition ensures we don't have a race condition where someone else updates the title first
book.update(title='Corrected Foo', conditions=(title=book.title,))

# 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")

# Query based on indexes
Book.ByAuthor.query(author="Mr. Bar")

Documentation

Full documentation is built from the sources each build and can be found online at:

https://nerdwalletoss.github.io/dynamorm/

The tests/ also contain the most complete documentation on how to actually use the library, so you are encouraged to read through them to really familiarize yourself with some of the more advanced concepts and use cases.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].