Skip to main content

A Dynamodb ORM

Project description

Quickstart

# Setup the db singleton
import boto3
from cerami import Cerami
dynamodb = boto3.client('dynamodb', endpoint_url="http://localhost:8000")
db = Cerami(dynamodb)


# create classes
import uuid
from cerami.datatype import String, Set, Datetime
from cerami.decorators import primary_key

@primary_key('_id', 'title')
class Book(db.Model):
    __tablename__ = "Books"

    _id = String(default=uuid.uuid4)
    title = String()
    authors = Set(String())
    publisher = String()
    book_producer = String()
    tags = Set(String())
    published = Datetime()
    rights = String()
    identifiers = String()
    comments = String()

# Query
Book.scan\
    .filter(Book.title.eq("Zac's First Book"))\
    .filter(Book.comments.eq("Awesome"))\
    .execute()

Book.query\
    .key_condition(Book._id.eq("XXX"))\
    .filter(Book.comments.eq("YYY"))\
    .execute()

Book.get\
    .key(Book.Schema._id.eq("XXX"))\
    .key(Book.Schema.title.eq("ZZZ"))\
    .execute()

Setup Dynamodb / boto3

First set up your virtualenv and install reqs.txt

You need to install the aws2 cli and have dynamo db running locally. Dynamodb requires java to run locally as well so good luck if you dont have it. Try these steps first and see how it goes.

Download DynamoDB Locally

  1. Download DynamoDB Locally
  2. Unzip/Untar the content
  3. Move to somewhere you wont lose it.

Download the AWS2 CLI

  1. Download the AWS2 CLI
  2. Follow the install instructions

Configure the AWS2 CLI

In order to run DynamoDB locally, you need to configure the cli as such:

aws2 configure
AWS Access Key ID: "fakeMyKeyId"
AWS Secret Access Key: "fakeSecretAccessKey"
us-west-1

Starting DynamoDB Locally

java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb

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

cerami-0.1.0.tar.gz (20.4 kB view hashes)

Uploaded Source

Built Distribution

cerami-0.1.0-py3-none-any.whl (47.3 kB view hashes)

Uploaded Python 3

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