Skip to main content

Integrates cassandra/cqlengine with ripozo to easily create cassandra backed Hypermedia/HATEOAS/REST apis

Project description


test status test coverage documentation

ripozo-cassandra is a ripozo-extension that provides a Manager that integrates cqlengine (and thereby Cassandra) with ripozo. It provides convience functions for generating resources. In particular it focues on creating shortcuts for CRUD+L type operations. It fully implements the BaseManager class that is provided in the ripozo package.


This is the minimal example of creating ripozo managers with ripozo-cassandra and integrating them with a resource. As you can see in the example, there are only three functional lines of code.

from cqlengine.models import Model
from cqlengine import columns, connection
from import create_keyspace, sync_table, delete_keyspace

from ripozo_cassandra import CQLManager

from uuid import uuid4

# Define your model
class Person(Model):
    id = columns.UUID(primary_key=True, default=lambda:uuid4())
    first_name = columns.Text()
    last_name = columns.Text()

# Setup cqlengine and sync the person table
keyspace_name = 'mykeyspace'
connection.setup([''], keyspace_name)

# This is where you define your manager
class PersonManageR(CQLManager):
    model = Person  # Assign the cqlengin model to the manager
    fields = ('id', 'first_name', 'last_name',) # Specify the fields to use for this manager

# This is the ripozo specific part.
# This creates a resource class that can be given
# to a dispatcher (e.g. the flask-ripozo package's FlaskDispatcher)
class PersonResource(ResourceBase):
    manager = PersonManager
    pks = ['id']

    # A retrieval method that will operate on the '/api/person' route
    # It retrieves the id, first_name, and last_name properties
    def get_person(cls, request):
        properties = self.manager.retrieve(request.url_params)
        return cls(properties=properties)

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

ripozo-cassandra-0.2.1.tar.gz (4.8 kB view hashes)

Uploaded Source

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