Skip to content

Latest commit

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date

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.

fromdypy.dbimportSingleItemimportuuiditem=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.

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

Secure PutItem

The SecureItem prevents items overwriting.

fromdypy.dbimportSecureItemitem=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

1 star

Watchers

1 watching

Forks

Contributors

Languages