Source

dynamodb-mapper / README.rst

Full commit
Jean-Tiare Le Bi… 71c1ad6 
Max Noel e38c1c9 
Jean-Tiare Le Bi… 6195869 


Jean-Tiare Le Bi… 71c1ad6 










Jean-Tiare Le Bi… 06ff9be 



Jean-Tiare Le Bi… 71c1ad6 


Max Noel 9410d3f 





Max Noel e38c1c9 
Jean-Tiare Le Bi… 06ff9be 
Max Noel e38c1c9 
Jean-Tiare Le Bi… 6195869 



Jean-Tiare Le Bi… 06ff9be 


Jean-Tiare Le Bi… 50835d1 


Jean-Tiare Le Bi… 06ff9be 


Jean-Tiare Le Bi… 50835d1 

Jean-Tiare Le Bi… 501eb34 

Jean-Tiare Le Bi… 06ff9be 



Max Noel e38c1c9 
Max Noel a7afdd9 

Max Noel e38c1c9 



Jean-Tiare Le Bi… d77ecbd 


Max Noel e38c1c9 
Jean-Tiare Le Bi… d77ecbd 



Max Noel e38c1c9 
Jean-Tiare Le Bi… d5360da 
Jean-Tiare Le Bi… d77ecbd 
Jean-Tiare Le Bi… 6f142a3 
Max Noel e38c1c9 

Jean-Tiare Le Bi… 6195869 

Jean-Tiare Le Bi… 06ff9be 
Max Noel a7afdd9 
Jean-Tiare Le Bi… 6195869 







Max Noel a7afdd9 

Max Noel e38c1c9 



Jean-Tiare Le Bi… d77ecbd 
Max Noel e38c1c9 



Jean-Tiare Le Bi… 71c1ad6 
Max Noel e38c1c9 
Jean-Tiare Le Bi… d77ecbd 
Max Noel e38c1c9 

Jean-Tiare Le Bi… d77ecbd 
Max Noel e38c1c9 



Jean-Tiare Le Bi… 06ff9be 







Dynamodb-mapper -- a DynamoDB object mapper, based on boto.

Presentation
============

`DynamoDB <http://aws.amazon.com/dynamodb/>`_ is a minimalistic NoSQL engine
provided by Amazon as a part of their AWS product.

**DynamoDB** allows you to stores documents composed of unicode strings or numbers
as well as sets of unicode strings and numbers. Each tables must define a hash
key and may define a range key. All other fields are optional.

**Dynamodb-mapper** brings a tiny abstraction layer over DynamoDB to overcome some
of the limitations with no performance compromise. It is highly inspired by the
mature `MoongoKit project <http://namlook.github.com/mongokit>`_

- **Full documentation**: http://dynamodb-mapper.readthedocs.org/en/latest/
- **Report bugs**: https://bitbucket.org/Ludia/dynamodb-mapper/issues
- **Download**: http://pypi.python.org/pypi/dynamodb-mapper

Requirements
============

The documentation currently assumes that you're running Boto 2.3.0 or later.
If you're not, then the API for query and scan changes. You will have to supply
raw condition dicts, as is done in boto itself.

Also note that Boto 2.3.1 or later is required for autoincrement_int hash keys.
Earlier versions will fail.

We assume you've correctly set your Boto credentials.

Example usage
=============


Quick install
-------------

::

    $ pip install dynamodb-mapper

If you have not yet configured Boto, you may simply

::

    $ export AWS_ACCESS_KEY_ID=<your id key here>
    $ export AWS_SECRET_ACCESS_KEY=<your secret key here>


First Model
-----------

::

    from dynamodb_mapper.model import DynamoDBModel


    class DoomMap(DynamoDBModel):
        __table__ = u"doom_map"
        __hash_key__ = u"episode"
        __range_key__ = u"map"
        __schema__ = {
            u"episode": int,
            u"map": int,
            u"name": unicode,
            u"cheats": set,
        }
        __defaults__ = {
            "cheats": set([u"Konami"]),
        }


Initial Table creation
----------------------

::

    conn = ConnectionBorg()
    conn.create_table(DoomMap, 10, 10, wait_for_active=True)


Model Usage
-----------

::

    e1m1 = DoomMap()
    e1m1.episode = 1
    e1m1.map = 1
    e1m1.name = u"Hangar"
    e1m1.cheats = set([u"idkfa", u"iddqd", u"idclip"])
    e1m1.save()


    # Later on, retrieve that same object from the DB...
    e1m1 = DoomMap.get(1, 1)

    # query all maps of episode 1
    e1_maps = DoomMap.query(hash_key=1)

    # query all maps of episode 1 with 'map' hash_key > 5
    from boto.dynamodb.condition import GT
    e1_maps_after_5 = DoomMap.query(
        hash_key=1,
        range_key_condition=GT(5))

Contribute
==========

Want to contribute, report a but of request a feature ? The development goes on
at Ludia's BitBucket account:

- **Report bugs**: https://bitbucket.org/Ludia/dynamodb-mapper/issues
- **Fork the code**: https://bitbucket.org/Ludia/dynamodb-mapper/overview