Skip to main content

Object mapper for Amazon's DynamoDB

Project description

flywheel

Master Build:

build coverage

0.1 Build:

build-0.1 coverage-0.1

Documentation:

http://flywheel.readthedocs.org/

Downloads:

http://pypi.python.org/pypi/flywheel

Source:

https://github.com/mathcamp/flywheel

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()

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


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.1.tar.gz (26.7 kB view details)

Uploaded Source

File details

Details for the file flywheel-0.1.1.tar.gz.

File metadata

  • Download URL: flywheel-0.1.1.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for flywheel-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ab83bcfa7d5775fde73a8a23d9055603cf47b602e84a39563c751dc9daacd6d2
MD5 f29e44ac120bc8a93d60c9ebe9075f83
BLAKE2b-256 12c04e44298d530844e99e6ffe37ae3ec6b6adec3dc30337617c2c1588342efe

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page