No project description provided
Project description
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.
Usage
Create a Serializer
for getting data into the native DynamoDB format:
serializer.serialize(value)
to serialize individual valuesserializer.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 valuesdeserializer.deserialize_item(mapping)
for complete items from the AWS SDK
Example
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', ())
]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ddbcereal-2.1.1.tar.gz
.
File metadata
- Download URL: ddbcereal-2.1.1.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6119eccfe43fb42720420c6d387bc7b4c00f07c8d584933da460ce8502ba2cc |
|
MD5 | a95bbda815fa6924cecef194a6526830 |
|
BLAKE2b-256 | 697f87d7ae0fbef703aa3952dec4144e8ff89cfd623bae0e37a3f2dd1ef19430 |
File details
Details for the file ddbcereal-2.1.1-py3-none-any.whl
.
File metadata
- Download URL: ddbcereal-2.1.1-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f9777845c6867460d89d765656dbf7f4c8d88772cbb3ad65a2647c077875833 |
|
MD5 | 3c5c891a37cf83af94440bfa3206f401 |
|
BLAKE2b-256 | fd4c53ffea4cdef0d6a51601a7b845e8e1a7f9f8fba43f12180394c12a9bb5e8 |