SQLAlchemy-style ORM 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 = GameScore('Alien Adventure', 'abc') >>> score.incr_(wins=1) >>> engine.sync(score)
Get all scores on Comet Quest that are over 9000:
>>> scores = engine.query(GameScore).filter(GameScore.top_score > 9000, ... title='Comet Quest').all()
Changelog
0.2.0
Breakage: Removing S3Type (no longer have boto as dependency)
Feature: Support Python 3.2 and 3.3
0.1.3
Bug fix: Some queries fail when global index has no range key
0.1.2
Bug fix: Field names can begin with an underscore
Feature: Models have a nice default __init__ method
0.1.1
Bug fix: Can call incr_() on models that have not been saved yet
Bug fix: Model comparison with None
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
Built Distribution
File details
Details for the file flywheel-0.2.0rc1.tar.gz
.
File metadata
- Download URL: flywheel-0.2.0rc1.tar.gz
- Upload date:
- Size: 24.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01fc5ea68b7a916e95ba9560c4ff4abfb158efb8710f94430909c6a39123af98 |
|
MD5 | be7199a73828d36519ce2615a4f22bde |
|
BLAKE2b-256 | 6ff64cfd8e1e1430f68abec34d1379ca31887686e1f0513ef50c67bc8774fd9b |
File details
Details for the file flywheel-0.2.0rc1-py2.py3-none-any.whl
.
File metadata
- Download URL: flywheel-0.2.0rc1-py2.py3-none-any.whl
- Upload date:
- Size: 29.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e27a77e43489c0ffcfe497ddaa311cca9eff9b2aa32907638897f84c4102319e |
|
MD5 | 1a2e69f6752c41b654f6fd69e651650a |
|
BLAKE2b-256 | 1d55711fa5954ff573abcdb95d452dce575dc9c3b33fb9cf9d344831548c86d2 |