Object mapper for Amazon's DynamoDB
Project description
flywheel
- Master Build:
- 0.1 Build:
- Documentation:
- Downloads:
- Source:
Object mapper for Amazon’s DynamoDB
Getting Started
This is what a basic model looks like (schema taken from this DynamoDB API documentation)
from flywheel import Model, Field, GlobalIndex class GameScore(Model): __metadata__ = { 'global_indexes': [ GlobalIndex('GameTitleIndex', 'title', 'top_score') ], } userid = Field(hash_key=True) title = Field(range_key=True) top_score = Field(data_type=int) top_score_time = Field(data_type=datetime) wins = Field(data_type=int) losses = Field(data_type=int) def __init__(self, title, userid): self.title = title self.userid = userid
Create a new top score:
>>> score = GameScore('Master Blaster', 'abc') >>> score.top_score = 9001 >>> score.top_score_time = datetime.utcnow() >>> engine.sync(score)
Get all top scores for a user:
>>> scores = engine.query(GameScore).filter(userid='abc').all()
Get the top score for Galaxy Invaders:
>>> top_score = engine.query(GameScore).filter(title='Galaxy Invaders')\ ... .first(desc=True)
Atomically increment a user’s “wins” count on Alien Adventure:
>>> score = self.engine.get(GameScore, userid='abc', title='Alien Adventure') >>> score.incr_(wins=1) >>> score.sync()
Get all scores on Comet Quest that are over 9000:
>>> scores = engine.query(GameScore).filter(GameScore.top_score > 9000, ... title='Comet Quest').all()
0.1.0
First public release
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
flywheel-0.1.0.tar.gz
(25.6 kB
view details)
File details
Details for the file flywheel-0.1.0.tar.gz
.
File metadata
- Download URL: flywheel-0.1.0.tar.gz
- Upload date:
- Size: 25.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46a1fbe91ff724dcff0ebf42558b19a3f8a9967eaa740d76b320935b4de62785 |
|
MD5 | 181f7c483604fa496ad500f33effe7eb |
|
BLAKE2b-256 | dec3ee38889258fc9b32ac993e9e8fc7dcee2036cd9d76768acbe1784c91f953 |