{"id":19852861,"url":"https://github.com/nerdwalletoss/dynamorm","last_synced_at":"2025-04-06T01:09:34.521Z","repository":{"id":8962896,"uuid":"60388650","full_name":"NerdWalletOSS/dynamorm","owner":"NerdWalletOSS","description":"Python object \u0026 relation mapping library for Amazon's DynamoDB service","archived":false,"fork":false,"pushed_at":"2024-02-04T23:10:19.000Z","size":594,"stargazers_count":101,"open_issues_count":32,"forks_count":38,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-30T00:07:46.250Z","etag":null,"topics":["dynamo","dynamodb","dynamodb-local","marshmallow","orm","python","python3","schematics"],"latest_commit_sha":null,"homepage":"https://nerdwalletoss.github.io/dynamorm/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NerdWalletOSS.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-04T02:11:25.000Z","updated_at":"2024-04-20T04:12:34.000Z","dependencies_parsed_at":"2024-06-18T19:53:18.407Z","dependency_job_id":"7b73d735-c0eb-4731-88c6-3115b0bcd402","html_url":"https://github.com/NerdWalletOSS/dynamorm","commit_stats":{"total_commits":109,"total_committers":11,"mean_commits":9.909090909090908,"dds":"0.42201834862385323","last_synced_commit":"1270a85ae25a1cc4d1993bd64c752733c3e12072"},"previous_names":["borgstrom/dynamallow"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NerdWalletOSS%2Fdynamorm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NerdWalletOSS%2Fdynamorm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NerdWalletOSS%2Fdynamorm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NerdWalletOSS%2Fdynamorm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NerdWalletOSS","download_url":"https://codeload.github.com/NerdWalletOSS/dynamorm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419860,"owners_count":20936012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dynamo","dynamodb","dynamodb-local","marshmallow","orm","python","python3","schematics"],"created_at":"2024-11-12T14:04:42.675Z","updated_at":"2025-04-06T01:09:34.500Z","avatar_url":"https://github.com/NerdWalletOSS.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"DynamORM\n========\n\n.. image:: https://img.shields.io/travis/NerdWalletOSS/dynamorm.svg\n           :target: https://travis-ci.org/NerdWalletOSS/dynamorm\n\n.. image:: https://img.shields.io/codecov/c/github/NerdWalletOSS/dynamorm.svg\n           :target: https://codecov.io/github/NerdWalletOSS/dynamorm\n\n.. image:: https://img.shields.io/pypi/v/dynamorm.svg\n           :target: https://pypi.python.org/pypi/dynamorm\n           :alt: Latest PyPI version\n\n.. image:: https://img.shields.io/pypi/pyversions/dynamorm.svg\n           :target: https://pypi.python.org/pypi/dynamorm\n           :alt: Supported Python Versions\n\n----\n\n*This package is a work in progress -- Feedback / Suggestions / Etc welcomed!*\n\nPython + DynamoDB ♡\n\nDynamORM (pronounced *Dynamo-R-M*) is a Python object \u0026 relation mapping library for Amazon's `DynamoDB`_ service.\n\nThe project has two goals:\n\n1. **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.\n\n2. **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.\n\n.. _DynamoDB: http://aws.amazon.com/dynamodb/\n.. _Dynamo v1 in boto to Dynamo v2 in boto: http://boto.cloudhackers.com/en/latest/migrations/dynamodb_v1_to_v2.html\n.. _new resource model in boto3: http://boto3.readthedocs.io/en/latest/guide/dynamodb.html\n.. _Marshmallow: https://marshmallow.readthedocs.io/en/latest/\n.. _Schematics: https://schematics.readthedocs.io/en/latest/\n\n\nSupported Schema Validation Libraries\n-------------------------------------\n\n* `Schematics`_ \u003e= 2.1.0\n* `Marshmallow`_ \u003e= 2.15.1\n\n\nExample\n-------\n\n.. code-block:: python\n\n    import datetime\n\n    from dynamorm import DynaModel, GlobalIndex, ProjectAll\n\n    # In this example we'll use Marshmallow, but you can also use Schematics too!\n    # You can see that you have to import the schema library yourself, it is not abstracted at all\n    from marshmallow import fields\n\n    # Our objects are defined as DynaModel classes\n    class Book(DynaModel):\n        # Define our DynamoDB properties\n        class Table:\n            name = 'prod-books'\n            hash_key = 'isbn'\n            read = 25\n            write = 5\n\n        class ByAuthor(GlobalIndex):\n            name = 'by-author'\n            hash_key = 'author'\n            read = 25\n            write = 5\n            projection = ProjectAll()\n\n        # Define our data schema, each property here will become a property on instances of the Book class\n        class Schema:\n            isbn = fields.String(validate=validate_isbn)\n            title = fields.String()\n            author = fields.String()\n            publisher = fields.String()\n\n            # NOTE: Marshmallow uses the `missing` keyword during deserialization, which occurs when we save\n            # an object to Dynamo and the attr has no value, versus the `default` keyword, which is used when\n            # we load a document from Dynamo and the value doesn't exist or is null.\n            year = fields.Number(missing=lambda: datetime.datetime.utcnow().year)\n\n\n    # Store new documents directly from dictionaries\n    Book.put({\n        \"isbn\": \"12345678910\",\n        \"title\": \"Foo\",\n        \"author\": \"Mr. Bar\",\n        \"publisher\": \"Publishorama\"\n    })\n\n    # Work with the classes as objects.  You can pass attributes from the schema to the constructor\n    foo = Book(isbn=\"12345678910\", title=\"Foo\", author=\"Mr. Bar\",\n               publisher=\"Publishorama\")\n    foo.save()\n\n    # Or assign attributes\n    foo = Book()\n    foo.isbn = \"12345678910\"\n    foo.title = \"Foo\"\n    foo.author = \"Mr. Bar\"\n    foo.publisher = \"Publishorama\"\n\n    # In all cases they go through Schema validation, calls to .put or .save can result in ValidationError\n    foo.save()\n\n    # You can then fetch, query and scan your tables.\n    # Get on the hash key, and/or range key\n    book = Book.get(isbn=\"12345678910\")\n\n    # Update items, with conditions\n    # Here our condition ensures we don't have a race condition where someone else updates the title first\n    book.update(title='Corrected Foo', conditions=(title=book.title,))\n\n    # Query based on the keys\n    Book.query(isbn__begins_with=\"12345\")\n\n    # Scan based on attributes\n    Book.scan(author=\"Mr. Bar\")\n    Book.scan(author__ne=\"Mr. Bar\")\n\n    # Query based on indexes\n    Book.ByAuthor.query(author=\"Mr. Bar\")\n\n\nDocumentation\n=============\n\nFull documentation is built from the sources each build and can be found online at:\n\nhttps://nerdwalletoss.github.io/dynamorm/\n\n\nThe ``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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerdwalletoss%2Fdynamorm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnerdwalletoss%2Fdynamorm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerdwalletoss%2Fdynamorm/lists"}