Skip to main content

SQLAlchemy-style ORM for Amazon's DynamoDB

Project description

Flywheel

Master Build:

build coverage

0.2 Build:

build-0.2 coverage-0.2

0.3 Build:

build-0.3 coverage-0.3

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

Changelog

0.3.0

  • Breakage: Engine namespace is slightly different. If you pass in a string it will be used as the table name prefix with no additional ‘-’ added.

0.2.1

  • Breakage: Certain queries may now require you to specify an index where it was auto-detected before

  • Feature: Queries can now filter on non-indexed fields

  • Feature: More powerful “sync-if” constraints

  • Feature: Can OR together filter constraints in queries

All changes are due to an update in the DynamoDB API

0.2.0

  • Breakage: Engine no longer accepts boto connections (using dynamo3 instead)

  • Breakage: Removing S3Type (no longer have boto as dependency)

  • Feature: Support Python 3.2 and 3.3

  • Feature: .count() terminator for queries

  • Feature: Can override throughputs in Engine.create_schema()

  • Bug fix: Engine namespace is truly isolated

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


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

Uploaded Source

Built Distribution

flywheel-0.3.0-py2.py3-none-any.whl (31.4 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

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

File hashes

Hashes for flywheel-0.3.0.tar.gz
Algorithm Hash digest
SHA256 04e5e2d718ba2378d6859f4df5bec954807a534842691e9ab459d01a10e7cec9
MD5 9550986e0318ae7bc4dd839abece5aec
BLAKE2b-256 b8184aa6f68858a69b09d9998c4c69a67b7adbfb5a3eaaec7c4d3c305a00b729

See more details on using hashes here.

File details

Details for the file flywheel-0.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for flywheel-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 01a94865ea0ae7e43aeda99034097b0e4259fe3ac140e85ee1b6602ef2a0b95b
MD5 0f6900ad1833516c0186f81c5653ada1
BLAKE2b-256 5a5d85d87c315b315e9143343a15f149ea1d9ec123eb74b8847a4b4a9994787c

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