SQLAlchemy-style ORM for Amazon's DynamoDB
Project description
Flywheel
========
:Build: |build|_ |coverage|_
:Documentation: http://flywheel.readthedocs.org/
:Downloads: http://pypi.python.org/pypi/flywheel
:Source: https://github.com/mathcamp/flywheel
.. |build| image:: https://travis-ci.org/mathcamp/flywheel.png?branch=master
.. _build: https://travis-ci.org/mathcamp/flywheel
.. |coverage| image:: https://coveralls.io/repos/mathcamp/flywheel/badge.png?branch=master
.. _coverage: https://coveralls.io/r/mathcamp/flywheel?branch=master
Object mapper for Amazon's DynamoDB
Getting Started
===============
This is what a basic model looks like (schema taken from this `DynamoDB
API documentation
<http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html>`_)
::
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.4.7
-----
* New ``index_pk_dict_`` method for constructing `exclusive_start_key` for index queries
0.4.6
-----
* Pass exclusive_start_key through to dynamo3
0.4.5
-----
* Bug fix: Calling refresh() could sometimes crash from unordered results.
0.4.4
-----
* Bug fix: Mutable field defaults are no longer shared among model instances
0.4.3
-----
* Bug fix: Incorrect ``ConditionalCheckFailedException`` when syncing changes to a Composite field.
* Allow ``DateTimeType`` to be stored as a naive datetime.
0.4.2
-----
* Make the ``dict``, ``list``, and ``bool`` types backwards-compatible with the old json-serialized format
* Allow queries to use ``in``, ``not null``, and a few other constraints that were missing
* Models are smarter about marking fields as dirty for sync
* Stopped using deprecated ``expected`` syntax for dynamo3
0.4.1
-----
* **Warning**: Stored datetime objects will now be timezone-aware
* **Warning**: Stored datetime objects will now keep their microseconds
0.4.0
-----
* **Breakage**: Dropping support for python 3.2 due to lack of botocore support
* **Breakage**: Changing the ``list``, ``dict``, and ``bool`` data types to use native DynamoDB types instead of JSON serializing
* **Breakage** and bug fix: Fixing serialization of ``datetime`` and ``date`` objects (for more info see the commit)
* Feature: Can now do 'contains' filters on lists
* Feature: Fields support multiple validation checks
* Feature: Fields have an easy way to enforce non-null values (``nullable=False``)
Data type changes are due to an `update in the DynamoDB API
<https://aws.amazon.com/blogs/aws/dynamodb-update-json-and-more/>`_
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
<http://aws.amazon.com/blogs/aws/improved-queries-and-updates-for-dynamodb/>`_
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
========
:Build: |build|_ |coverage|_
:Documentation: http://flywheel.readthedocs.org/
:Downloads: http://pypi.python.org/pypi/flywheel
:Source: https://github.com/mathcamp/flywheel
.. |build| image:: https://travis-ci.org/mathcamp/flywheel.png?branch=master
.. _build: https://travis-ci.org/mathcamp/flywheel
.. |coverage| image:: https://coveralls.io/repos/mathcamp/flywheel/badge.png?branch=master
.. _coverage: https://coveralls.io/r/mathcamp/flywheel?branch=master
Object mapper for Amazon's DynamoDB
Getting Started
===============
This is what a basic model looks like (schema taken from this `DynamoDB
API documentation
<http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html>`_)
::
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.4.7
-----
* New ``index_pk_dict_`` method for constructing `exclusive_start_key` for index queries
0.4.6
-----
* Pass exclusive_start_key through to dynamo3
0.4.5
-----
* Bug fix: Calling refresh() could sometimes crash from unordered results.
0.4.4
-----
* Bug fix: Mutable field defaults are no longer shared among model instances
0.4.3
-----
* Bug fix: Incorrect ``ConditionalCheckFailedException`` when syncing changes to a Composite field.
* Allow ``DateTimeType`` to be stored as a naive datetime.
0.4.2
-----
* Make the ``dict``, ``list``, and ``bool`` types backwards-compatible with the old json-serialized format
* Allow queries to use ``in``, ``not null``, and a few other constraints that were missing
* Models are smarter about marking fields as dirty for sync
* Stopped using deprecated ``expected`` syntax for dynamo3
0.4.1
-----
* **Warning**: Stored datetime objects will now be timezone-aware
* **Warning**: Stored datetime objects will now keep their microseconds
0.4.0
-----
* **Breakage**: Dropping support for python 3.2 due to lack of botocore support
* **Breakage**: Changing the ``list``, ``dict``, and ``bool`` data types to use native DynamoDB types instead of JSON serializing
* **Breakage** and bug fix: Fixing serialization of ``datetime`` and ``date`` objects (for more info see the commit)
* Feature: Can now do 'contains' filters on lists
* Feature: Fields support multiple validation checks
* Feature: Fields have an easy way to enforce non-null values (``nullable=False``)
Data type changes are due to an `update in the DynamoDB API
<https://aws.amazon.com/blogs/aws/dynamodb-update-json-and-more/>`_
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
<http://aws.amazon.com/blogs/aws/improved-queries-and-updates-for-dynamodb/>`_
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
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.4.7.tar.gz
(29.0 kB
view details)
Built Distribution
File details
Details for the file flywheel-0.4.7.tar.gz
.
File metadata
- Download URL: flywheel-0.4.7.tar.gz
- Upload date:
- Size: 29.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71fdc239d1b75a16f99d68aa69ab6c5c819e922840489d83348e46eb9e968435 |
|
MD5 | 57a5185446bfe0096e5791ff89488aa0 |
|
BLAKE2b-256 | 76858ab48a80b1c64afd44e1890d5098504c0657512134177a38d65ec35f2e3a |
File details
Details for the file flywheel-0.4.7-py2.py3-none-any.whl
.
File metadata
- Download URL: flywheel-0.4.7-py2.py3-none-any.whl
- Upload date:
- Size: 34.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3a30f39f9b1ac7de1eab1c903abc63639ae549e3153fbc3dcaef6f0223d5eef |
|
MD5 | 216fc5483aa31bf6a775fb5c925adc41 |
|
BLAKE2b-256 | ada5c4cf218745ec7ebf1deb82ed56422f805c621a800e457f36ff8f77c405c7 |