Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

noize-e/dyno.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

Dyno.py

A python client designed to work with AWS DynamoDB following the SingleTable schema model.

Ops

PutItem

This operation requires a partition key and optionally a sort key.

from dypy.db import SingleItem
import uuid


item = SingleItem(pk='user@email.com', sk=uuid.uuid4().hex, name='Frank')

Create a new Table instance, call the put method passing the SingleItem object to execute the operation.

...

response = Table('TableName').put(item)

Use the ok attribute to validate if the request was successful.

...

if response.ok:
    print("Item saved", item.data())

Secure PutItem

The SecureItem prevents items overwriting.

from dypy.db import SecureItem

item = SecureItem(pk='user@email.com', sk=uuid.uuid4().hex, name='Frank')
response = Table('TableName').put(item)

DynamoDB-JSON Parse

Convert JSON to DynamoJSON

Usage

# shell command
dynamojson --dump 'your.json' 'TableName' 
[
  {
    "uid": 1,
    "salt": "$2B$12$Pfsv3Tw6Rakclh/Ustdc3U",
    "media": { 
      "content": "/media1/live-radio-session-1.m3u8",
    }
  }
]

Dump:

{
  "TableName": [
    {
      "PutRequest": {
        "Item": {
          "uid": {
            "N": "1"
          },
          "salt": {
            "S": "$2B$12$Pfsv3Tw6Rakclh/Ustdc3U"
          },
          "media": {
            "M": {
              "content": {
                "S": "/media1/live-radio-session-1.m3u8"
              }
            }
          }
        }
      }
    }
  ]
}

About

Python utilities to work with AWS DynamoDB

Topics

Resources

Stars

Watchers

Forks

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.