A lightweight library for interacting with AWS dynamoDB in a pythonic way,inspired by pymongo
Project description
dynamongo is Python ORM/framework-agnostic library for DynamoDB. It is highly inspired by the PyMongo project. This documentation attempts to explain everything you need to know to use dynamongo.
import datetime
from dynamongo import Model, Connection
from dynamongo import IntField, StringField, ListField, EmailField, DateTimeField
# This only need be called once. Alternatively, it can be set using env variables
Connection.set_config(
access_key_id='<KEY>',
secret_access_key='<SECRET>',
table_prefix='test-'
)
class User(Model):
__table__ = 'users'
__hash_key__ = 'email'
email = EmailField(required=True)
name = StringField(required=True)
year_of_birth = IntField(max_value=2018, min_value=1900)
cities_visited = ListField(StringField)
created_at = DateTimeField(default=datetime.datetime.now)
# store data to DynamoDB
john = User.save_one({
'email': 'johndoe@gmail.com',
'name': 'John Doe',
'year_of_birth': 1990,
'cities_visited': ['Nairobi', 'New York']
})
# year_of_birth, cities_visited & created_at are all optional
jane = User.save_one({
'email': 'jane@gmail.com',
'name': 'Jane Doe'
})
# Access attribute values
print(john.name)
# Fetch data from dynamoDB
user = User.get_one(User.email == 'johndoe@gmail.com')
print(user.to_dict())
In short, dynamongo models can be used to easily:
validate input data
save serialized data to DynamoDB
read and deserialize data from DynamoDB
delete items from DynamoDB
update data in DynamoDB
Get It Now
$ pip install dynamongo
Documentation
Full documentation is available at http://dynamongo.readthedocs.io/ .
Requirements
Python >= 3.5
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dynamongo-0.1.tar.gz
(31.2 kB
view details)
File details
Details for the file dynamongo-0.1.tar.gz
.
File metadata
- Download URL: dynamongo-0.1.tar.gz
- Upload date:
- Size: 31.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.5.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6edb535a52ff816c16124a342ca583741f25fdbf5b0a560067d82dda9fe3e03 |
|
MD5 | aad7d8ab4c8994ddd325f7297a8a2266 |
|
BLAKE2b-256 | 5ea771c0a7b8e4bf20acb953e9cf282f62bbb627e06f1cf9360e07a3970db7a8 |