simplesingletable


Namesimplesingletable JSON
Version 4.0.0 PyPI version JSON
download
home_pageNone
SummaryA simple boto3/Pydantic implementation of DynamoDB Single Table Design and related utilities.
upload_time2024-04-16 16:36:14
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseThe MIT License (MIT) Copyright © 2023 <copyright holders> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords dynamodb singletabledesign
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Simple Single Table

**Latest Version:** 4.0.0

**simplesingletable** is a Python library that offers an abstraction layer for AWS DynamoDB operations, particularly for
those tables using single-table design. It uses Pydantic to define the models, and tries to be as "batteries-included"
based on how I personally have come to use DynamoDb.

I've used and written variations of this same code many times, and finally decided to try and package it all up into a
single library I could pip install and use whenever I needed cheap, easy, fast storage with few access patterns. So far
this is working quite well for the way I use DynamoDb and the assumptions that are true for me, such as:

* My apps are generally pretty small scale -- a few hundred users at a time max
* My collection sizes are pretty small -- tens or hundreds of thousands, not millions or billions

In this scenario I've found DynamoDb to be an extremely valuable tool that can perform extremely fast and consistently,
and essentially for free or very little cost. I believe most of these tools and techniques would scale beyond that,
but cannot personally attest to it.

## Key Features

There are many ways to use DynamoDb. These are the things I've come to want:

* A single table where I can store different types of Objects (Pydantic Models)
* Automatic resource ID creation using a lexicographically sortable ID (via `ulid-py`); this is very useful for setting
  up alternative access patterns using the secondary indices and having them sort by creation date of the objects.
* Simple way to list, paginate, and filter by object type, sortable by last updated time, seamlessly blending DynamoDb
  filter expressions and server side filtering on the loaded Pydantic models using simple python functions
* Automatic versioning for created resources -- every update generates a new version, and the complete version history
  is maintained and easily accessed; additionally the code prevents simultaneous writes from the same version; updates
  can only be performed from the latest version of an object.
* Powerful query function for enabling secondary access patterns using GSIs as needed

## Installation:

```bash
pip install simplesingletable
```

# Usage

Docs, examples, and access patterns coming soon!

Here's a brief demo of how to utilize:

```python

# How to Use:
# 1. Define a Resource:
# Resources are essentially DynamoDB items. They can be defined by subclassing `DynamodbVersionedResource`:

from simplesingletable import DynamodbVersionedResource, DynamoDBMemory


class MyTestResource(DynamodbVersionedResource):
    some_field: str
    bool_field: bool
    list_of_things: list[str | int | bool | float]


# 2. CRUD Operations
from logzero import logger

dynamodb_memory = DynamoDBMemory(logger=logger, table_name="my-dynamodb-table")
resource = dynamodb_memory.create_new(MyTestResource, {})
retrieved = dynamodb_memory.read_existing(resource.resource_id, MyTestResource)
updated_resource = dynamodb_memory.update_existing(retrieved, {})
```

More coming soon...

# Testing:

The package includes a comprehensive test suite to ensure reliability and robustness. Use the test_simplesingletable.py
as a reference for the functionalities available until more documentation is available.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "simplesingletable",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "dynamodb, singletabledesign",
    "author": null,
    "author_email": "Sully <sully@sadburger.com>",
    "download_url": "https://files.pythonhosted.org/packages/d4/1e/7c587fe3d2782db27f6e1146d0a55a0123720193ba83a306ac1c5b8abb2b/simplesingletable-4.0.0.tar.gz",
    "platform": null,
    "description": "# Simple Single Table\n\n**Latest Version:** 4.0.0\n\n**simplesingletable** is a Python library that offers an abstraction layer for AWS DynamoDB operations, particularly for\nthose tables using single-table design. It uses Pydantic to define the models, and tries to be as \"batteries-included\"\nbased on how I personally have come to use DynamoDb.\n\nI've used and written variations of this same code many times, and finally decided to try and package it all up into a\nsingle library I could pip install and use whenever I needed cheap, easy, fast storage with few access patterns. So far\nthis is working quite well for the way I use DynamoDb and the assumptions that are true for me, such as:\n\n* My apps are generally pretty small scale -- a few hundred users at a time max\n* My collection sizes are pretty small -- tens or hundreds of thousands, not millions or billions\n\nIn this scenario I've found DynamoDb to be an extremely valuable tool that can perform extremely fast and consistently,\nand essentially for free or very little cost. I believe most of these tools and techniques would scale beyond that,\nbut cannot personally attest to it.\n\n## Key Features\n\nThere are many ways to use DynamoDb. These are the things I've come to want:\n\n* A single table where I can store different types of Objects (Pydantic Models)\n* Automatic resource ID creation using a lexicographically sortable ID (via `ulid-py`); this is very useful for setting\n  up alternative access patterns using the secondary indices and having them sort by creation date of the objects.\n* Simple way to list, paginate, and filter by object type, sortable by last updated time, seamlessly blending DynamoDb\n  filter expressions and server side filtering on the loaded Pydantic models using simple python functions\n* Automatic versioning for created resources -- every update generates a new version, and the complete version history\n  is maintained and easily accessed; additionally the code prevents simultaneous writes from the same version; updates\n  can only be performed from the latest version of an object.\n* Powerful query function for enabling secondary access patterns using GSIs as needed\n\n## Installation:\n\n```bash\npip install simplesingletable\n```\n\n# Usage\n\nDocs, examples, and access patterns coming soon!\n\nHere's a brief demo of how to utilize:\n\n```python\n\n# How to Use:\n# 1. Define a Resource:\n# Resources are essentially DynamoDB items. They can be defined by subclassing `DynamodbVersionedResource`:\n\nfrom simplesingletable import DynamodbVersionedResource, DynamoDBMemory\n\n\nclass MyTestResource(DynamodbVersionedResource):\n    some_field: str\n    bool_field: bool\n    list_of_things: list[str | int | bool | float]\n\n\n# 2. CRUD Operations\nfrom logzero import logger\n\ndynamodb_memory = DynamoDBMemory(logger=logger, table_name=\"my-dynamodb-table\")\nresource = dynamodb_memory.create_new(MyTestResource, {})\nretrieved = dynamodb_memory.read_existing(resource.resource_id, MyTestResource)\nupdated_resource = dynamodb_memory.update_existing(retrieved, {})\n```\n\nMore coming soon...\n\n# Testing:\n\nThe package includes a comprehensive test suite to ensure reliability and robustness. Use the test_simplesingletable.py\nas a reference for the functionalities available until more documentation is available.\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT) Copyright \u00a9 2023 <copyright holders>  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \u201cAS IS\u201d, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A simple boto3/Pydantic implementation of DynamoDB Single Table Design and related utilities.",
    "version": "4.0.0",
    "project_urls": {
        "Homepage": "https://github.com/msull/simplesingletable"
    },
    "split_keywords": [
        "dynamodb",
        " singletabledesign"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8ad75bd9dfc58c1890347c14368fdf594518403337b78c58f6ac0d2a6e4e87db",
                "md5": "7eb79e7bf87f50657d6e0ef073f889dc",
                "sha256": "d6039032ad0fd0fbc25f495dee8d1aa3fa1e2d1601123fc7eab3dac1a67358c3"
            },
            "downloads": -1,
            "filename": "simplesingletable-4.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7eb79e7bf87f50657d6e0ef073f889dc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 29104,
            "upload_time": "2024-04-16T16:36:12",
            "upload_time_iso_8601": "2024-04-16T16:36:12.983363Z",
            "url": "https://files.pythonhosted.org/packages/8a/d7/5bd9dfc58c1890347c14368fdf594518403337b78c58f6ac0d2a6e4e87db/simplesingletable-4.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d41e7c587fe3d2782db27f6e1146d0a55a0123720193ba83a306ac1c5b8abb2b",
                "md5": "038cc0d2dd091b0a02ca33b2f295123b",
                "sha256": "7ced7862dd46493e31a48dcec867cc90011f54c18717acba1bc598006ca53978"
            },
            "downloads": -1,
            "filename": "simplesingletable-4.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "038cc0d2dd091b0a02ca33b2f295123b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 30355,
            "upload_time": "2024-04-16T16:36:14",
            "upload_time_iso_8601": "2024-04-16T16:36:14.367516Z",
            "url": "https://files.pythonhosted.org/packages/d4/1e/7c587fe3d2782db27f6e1146d0a55a0123720193ba83a306ac1c5b8abb2b/simplesingletable-4.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-16 16:36:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "msull",
    "github_project": "simplesingletable",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "simplesingletable"
}
        
Elapsed time: 0.23655s