dynamodb-mapper-features /

Filename Size Date modified Message
193 B
705 B
1.6 KB
7.5 KB
1.5 KB
851 B
364 B

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


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.

Example usage

We assume you've correctly set your Boto credentials.

Your Model

from dynamodb_mapper.model import DynamoDBModel

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

Initial Table creation

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

Model Usage

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

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

# query on hash+range-keyed tables
e1_maps = DoomMap.query(hash_key=1)

from boto.dynamodb.condition import GT
e1_maps_after_5 = DoomMap.query(
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.