ddbcereal


Nameddbcereal JSON
Version 2.1.1 PyPI version JSON
download
home_pagehttps://github.com/JustinTArthur/ddbcereal
Summary
upload_time2021-08-10 05:41:28
maintainer
docs_urlNone
authorJustin Turner Arthur
requires_python>=3.6
licenseApache License 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ddbcereal
A high performance Python library for serializing and deserializing DynamoDB
attribute values.

Serializers and deserializers created with ddbcereal work with the input and
output of AWS SDKs like botocore, aiobotocore, and the low-level client
interfaces of boto3 and aioboto3.

This library endeavors to be at least as fast as boto3's (de)serializer and has
the option to work with inexact numbers like floats.

[Documentation](https://ddbcereal.readthedocs.io/)

## Usage
Create a `Serializer` for getting data into the native DynamoDB format:
* `serializer.serialize(value)` to serialize individual values
* `serializer.serialize_item(mapping)` to serialize an entire dict of values.
  
Create `Deserializer` for getting native DynamoDB data into native Python values:
* `deserializer.deserialize(value)` to deserialize individual values
* `deserializer.deserialize_item(mapping)` for complete items from the AWS SDK

## Example
```python
import aiobotocore
import ddbcereal

serializer = ddbcereal.Serializer()
deserializer = ddbcereal.Deserializer()

aws = aiobotocore.Session()

async with aws.create_client('dynamodb') as ddb:
    # Serialize entire dict as a DynamoDB item
    await ddb.put_item(
        TableName='MyItems',
        Item=serializer.serialize_item(my_dict)
    )

    # Serialize single values
    await ddb.update_item(
        TableName='Customers',
        Key={'id': serializer.serialize(customer_id)},
        UpdateExpression='SET displayName = :name, licenses = :licenses',
        ExpressionAttributeValues={
            ':name': serializer.serialize('ACME, Inc.'),
            ':licenses': serializer.serialize(20)
        }
    )

    # Deserializing:
    response = await ddb.query(
            TableName='Companies',
            KeyConditionExpression='id = :id',
            ExpressionAttributeValues={
                ':id': serializer.serialize(customer_id)
            }
        )
    companies = [
        deserializer.deserialize_item(item)
        for item in response.get('Items', ())
    ]
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/JustinTArthur/ddbcereal",
    "name": "ddbcereal",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Justin Turner Arthur",
    "author_email": "justinarthur@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/69/7f/87d7ae0fbef703aa3952dec4144e8ff89cfd623bae0e37a3f2dd1ef19430/ddbcereal-2.1.1.tar.gz",
    "platform": "",
    "description": "# ddbcereal\nA high performance Python library for serializing and deserializing DynamoDB\nattribute values.\n\nSerializers and deserializers created with ddbcereal work with the input and\noutput of AWS SDKs like botocore, aiobotocore, and the low-level client\ninterfaces of boto3 and aioboto3.\n\nThis library endeavors to be at least as fast as boto3's (de)serializer and has\nthe option to work with inexact numbers like floats.\n\n[Documentation](https://ddbcereal.readthedocs.io/)\n\n## Usage\nCreate a `Serializer` for getting data into the native DynamoDB format:\n* `serializer.serialize(value)` to serialize individual values\n* `serializer.serialize_item(mapping)` to serialize an entire dict of values.\n  \nCreate `Deserializer` for getting native DynamoDB data into native Python values:\n* `deserializer.deserialize(value)` to deserialize individual values\n* `deserializer.deserialize_item(mapping)` for complete items from the AWS SDK\n\n## Example\n```python\nimport aiobotocore\nimport ddbcereal\n\nserializer = ddbcereal.Serializer()\ndeserializer = ddbcereal.Deserializer()\n\naws = aiobotocore.Session()\n\nasync with aws.create_client('dynamodb') as ddb:\n    # Serialize entire dict as a DynamoDB item\n    await ddb.put_item(\n        TableName='MyItems',\n        Item=serializer.serialize_item(my_dict)\n    )\n\n    # Serialize single values\n    await ddb.update_item(\n        TableName='Customers',\n        Key={'id': serializer.serialize(customer_id)},\n        UpdateExpression='SET displayName = :name, licenses = :licenses',\n        ExpressionAttributeValues={\n            ':name': serializer.serialize('ACME, Inc.'),\n            ':licenses': serializer.serialize(20)\n        }\n    )\n\n    # Deserializing:\n    response = await ddb.query(\n            TableName='Companies',\n            KeyConditionExpression='id = :id',\n            ExpressionAttributeValues={\n                ':id': serializer.serialize(customer_id)\n            }\n        )\n    companies = [\n        deserializer.deserialize_item(item)\n        for item in response.get('Items', ())\n    ]\n```\n\n\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "",
    "version": "2.1.1",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "3c5c891a37cf83af94440bfa3206f401",
                "sha256": "1f9777845c6867460d89d765656dbf7f4c8d88772cbb3ad65a2647c077875833"
            },
            "downloads": -1,
            "filename": "ddbcereal-2.1.1-py3-none-any.whl",
            "has_sig": true,
            "md5_digest": "3c5c891a37cf83af94440bfa3206f401",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 12926,
            "upload_time": "2021-08-10T05:41:27",
            "upload_time_iso_8601": "2021-08-10T05:41:27.583766Z",
            "url": "https://files.pythonhosted.org/packages/fd/4c/53ffea4cdef0d6a51601a7b845e8e1a7f9f8fba43f12180394c12a9bb5e8/ddbcereal-2.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "a95bbda815fa6924cecef194a6526830",
                "sha256": "a6119eccfe43fb42720420c6d387bc7b4c00f07c8d584933da460ce8502ba2cc"
            },
            "downloads": -1,
            "filename": "ddbcereal-2.1.1.tar.gz",
            "has_sig": true,
            "md5_digest": "a95bbda815fa6924cecef194a6526830",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 11009,
            "upload_time": "2021-08-10T05:41:28",
            "upload_time_iso_8601": "2021-08-10T05:41:28.917387Z",
            "url": "https://files.pythonhosted.org/packages/69/7f/87d7ae0fbef703aa3952dec4144e8ff89cfd623bae0e37a3f2dd1ef19430/ddbcereal-2.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-08-10 05:41:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "JustinTArthur",
    "github_project": "ddbcereal",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ddbcereal"
}
        
Elapsed time: 0.26089s