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.0.tar.gz (9.0 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.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dynamodb_serialise-1.1.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dynamodb_serialise-1.1.0.tar.gz
Algorithm Hash digest
SHA256 339526058a626af46a035f5117b0824b2d0ea31ce06a9ac644a8d79756c64605
MD5 4e865a7908d5cf89deb6d171937a3f14
BLAKE2b-256 1363fd8c7f2ebb300deab61b0c9633e8ea6016049a10ed5a9c141d44d9028f52

See more details on using hashes here.

Provenance

The following attestation bundles were made for dynamodb_serialise-1.1.0.tar.gz:

Publisher: publish-python-package.yml on EpicWink/dynamodb-serialise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for dynamodb_serialise-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ceb2ee9bc1ea80d296a5dc99d02215e715ecfbbaaed2358399430bdf1478ad86
MD5 7b854eb45bb34136f0576e00b2f2e572
BLAKE2b-256 1ce324ab04c764ebf42fda8547956ae4e97602dd253bc04b7e0fb2e365c450e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for dynamodb_serialise-1.1.0-py3-none-any.whl:

Publisher: publish-python-package.yml on EpicWink/dynamodb-serialise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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