Skip to main content

DynamoDB value serialisation and deserialisation

Project description

DynamoDB value serialisation and deserialisation

Convert values from AWS DynamoDB to native Python types.

Makes more sensible decisions about numbers and binary values, at the cost of floating-point precision. Very lightweight.

Installation

pip install dynamodb-serialise

Usage

import dynamodb_serialise

dynamodb_serialise.deserialise(
    {"M": {"foo": {"N": "42"}, "bar": {"B": "c3BhbQ=="}}}
)
# {'foo': 42, 'bar': b'spam'}

dynamodb_serialise.serialise(
    {'foo': 42, 'bar': b'spam'}, bytes_to_base64=True
)
# {"M": {"foo": {"N": "42"}, "bar": {"B": "c3BhbQ=="}}}

Command-line

Can be run to transform values at the command-line, transforming stdin to stdout as JSON. Pass -d to deserialise instead of serialise.

The following example uses AWS CLI (aws) to produce DynamoDB values in lists of objects, jq to convert the scan result to full DynamoDB values, and dynamodb-serialise to convert to native types.

aws dynamodb scan \
  --table-name my-table \
  | jq '{ L: .Items | map({ M: . }) }' \
  | python3 -m dynamodb_serialise -d

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

dynamodb_serialise-1.1.0b0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dynamodb_serialise-1.1.0b0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file dynamodb_serialise-1.1.0b0.tar.gz.

File metadata

  • Download URL: dynamodb_serialise-1.1.0b0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for dynamodb_serialise-1.1.0b0.tar.gz
Algorithm Hash digest
SHA256 c6ab353580ff4ee6b562a7815df759a54ca40adf5e68ed2a62a896a37d6e2ae1
MD5 498b6af74f3d31303222fea3c1de19c0
BLAKE2b-256 632b99f1a973023595a3fa389be120d758c1d12dfa09aee13cf1652e7902aaa9

See more details on using hashes here.

File details

Details for the file dynamodb_serialise-1.1.0b0-py3-none-any.whl.

File metadata

File hashes

Hashes for dynamodb_serialise-1.1.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 e4e2c1ba2947679f6553d6b3b94f1a170f68df82c88000212bc99832ff5c77eb
MD5 0d0da4a04fc68ceb0f3bd1b52a846031
BLAKE2b-256 fc9d3e0f993dc672e3baae81cbb2037bcc4e5bb7ae05ab5122024e08b04cf6f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page