simplesingletable


Namesimplesingletable JSON
Version 2.3.2 PyPI version JSON
download
home_page
SummaryA simple boto3/Pydantic implementation of DynamoDB Single Table Design and related utilities.
upload_time2024-02-13 00:50:17
maintainer
docs_urlNone
author
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:** 2.3.2

**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": "",
    "name": "simplesingletable",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "dynamodb,singletabledesign",
    "author": "",
    "author_email": "Sully <sully@sadburger.com>",
    "download_url": "https://files.pythonhosted.org/packages/09/c6/3f9cfa003b48b90980d5ea98d7278dde6a8695a07adc718983722cbd10ab/simplesingletable-2.3.2.tar.gz",
    "platform": null,
    "description": "# Simple Single Table\n\n**Latest Version:** 2.3.2\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": "2.3.2",
    "project_urls": {
        "Homepage": "https://github.com/msull/simplesingletable"
    },
    "split_keywords": [
        "dynamodb",
        "singletabledesign"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4cc9fef44129ab9df8aab9bf94314d424a52f54eb9f3bdd263e237859ea31d83",
                "md5": "16668961dbc2781b851a34af61d2e66a",
                "sha256": "1859e867a61fcfceb58e87a4a66481a7ad5700ae2f89bfa4d3f93777fe28fda8"
            },
            "downloads": -1,
            "filename": "simplesingletable-2.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "16668961dbc2781b851a34af61d2e66a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 16393,
            "upload_time": "2024-02-13T00:50:15",
            "upload_time_iso_8601": "2024-02-13T00:50:15.303894Z",
            "url": "https://files.pythonhosted.org/packages/4c/c9/fef44129ab9df8aab9bf94314d424a52f54eb9f3bdd263e237859ea31d83/simplesingletable-2.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "09c63f9cfa003b48b90980d5ea98d7278dde6a8695a07adc718983722cbd10ab",
                "md5": "d3e9a1abf74416be63688ab1ff4fe481",
                "sha256": "6005afd78e062b642a63b43874f01533eb31dbaf96ed7f66e7bad729c7b8928d"
            },
            "downloads": -1,
            "filename": "simplesingletable-2.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "d3e9a1abf74416be63688ab1ff4fe481",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 18951,
            "upload_time": "2024-02-13T00:50:17",
            "upload_time_iso_8601": "2024-02-13T00:50:17.124060Z",
            "url": "https://files.pythonhosted.org/packages/09/c6/3f9cfa003b48b90980d5ea98d7278dde6a8695a07adc718983722cbd10ab/simplesingletable-2.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-13 00:50:17",
    "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.22986s