Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stevearc/flywheel
Object mapper for Amazon's DynamoDB
https://github.com/stevearc/flywheel
aws dynamodb orm python
Last synced: 8 days ago
JSON representation
Object mapper for Amazon's DynamoDB
- Host: GitHub
- URL: https://github.com/stevearc/flywheel
- Owner: stevearc
- License: mit
- Archived: true
- Created: 2013-12-21T19:59:08.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2021-12-26T03:38:21.000Z (almost 3 years ago)
- Last Synced: 2024-05-21T04:34:09.535Z (6 months ago)
- Topics: aws, dynamodb, orm, python
- Language: Python
- Size: 444 KB
- Stars: 128
- Watchers: 13
- Forks: 25
- Open Issues: 11
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
- License: LICENSE
Awesome Lists containing this project
- awesome-python-models - flywheel - Object mapper for Amazon's DynamoDB. (ODM, ORM, Active Record)
README
Flywheel
========
:Build: |build|_ |coverage|_
:Documentation: http://flywheel.readthedocs.org/
:Downloads: http://pypi.python.org/pypi/flywheel
:Source: https://github.com/stevearc/flywheel.. |build| image:: https://travis-ci.org/stevearc/flywheel.png?branch=master
.. _build: https://travis-ci.org/stevearc/flywheel
.. |coverage| image:: https://coveralls.io/repos/stevearc/flywheel/badge.png?branch=master
.. _coverage: https://coveralls.io/r/stevearc/flywheel?branch=masterObject mapper for Amazon's DynamoDB
**END OF LIFE WARNING**: I haven't personally used this project, or even written
much python, since early 2014. I will continue to respond to bugs and pull
requests, but I am no longer doing active development. My apologies to those of
you who have come to rely on Flywheel; I wish I had the time to continue it. If
there is anyone in the community interested in becoming the new maintainer and
continuing to move development forward, send me an email and we can discuss.If you are looking for an alternative, I can recommend `PynamoDB
`_.Getting Started
===============
This is what a basic model looks like (schema taken from this `DynamoDB
API documentation
`_).. sourcecode:: python
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(type=int)
top_score_time = Field(type=datetime)
wins = Field(type=int)
losses = Field(type=int)def __init__(self, title, userid):
self.title = title
self.userid = useridCreate a new top score
.. sourcecode:: python
>>> 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
.. sourcecode:: python
>>> scores = engine.query(GameScore).filter(userid='abc').all()
Get the top score for Galaxy Invaders
.. sourcecode:: python
>>> top_score = engine.query(GameScore).filter(title='Galaxy Invaders')\
... .first(desc=True)Atomically increment a user's "wins" count on Alien Adventure
.. sourcecode:: python
>>> score = GameScore('Alien Adventure', 'abc')
>>> score.incr_(wins=1)
>>> engine.sync(score)Get all scores on Comet Quest that are over 9000
.. sourcecode:: python
>>> scores = engine.query(GameScore).filter(GameScore.top_score > 9000,
... title='Comet Quest').all()