Go to file
Jon Haddad 37259b963e Getting connection pooling working with mocking library
Verified throwing exception when no servers are available,
but correctly recovering and hitting the next server when
one is.

fixing minor pooling tests

ensure we get the right exception back when no servers are available

working on tests for retry

connections working despite failure

Removed old connection_manager and replaced with a simple context
manager that allows for easy access to clients within the main pool
2013-06-03 17:33:00 -07:00
2013-06-03 15:49:15 -07:00
2012-11-12 22:04:12 -08:00
2013-05-13 14:45:41 +02:00
2012-12-04 22:47:47 -08:00
2013-06-03 13:28:26 -07:00
2013-06-03 10:11:38 -07:00
2012-11-25 11:00:42 -08:00
2012-11-25 18:56:38 -08:00
2013-06-03 15:49:15 -07:00
2012-12-13 20:58:20 -08:00

cqlengine

cqlengine is a Cassandra CQL 3 Object Mapper for Python with an interface similar to the Django orm and mongoengine

Documentation

Report a Bug

Users Mailing List

Dev Mailing List

Installation

pip install cqlengine

Getting Started

#first, define a model
from cqlengine import columns
from cqlengine.models import Model

class ExampleModel(Model):
    read_repair_chance = 0.05 # optional - defaults to 0.1
    example_id      = columns.UUID(primary_key=True)  
    example_type    = columns.Integer(index=True)
    created_at      = columns.DateTime()
    description     = columns.Text(required=False)

#next, setup the connection to your cassandra server(s)...
>>> from cqlengine import connection
>>> connection.setup(['127.0.0.1:9160'])

#...and create your CQL table
>>> from cqlengine.management import create_table
>>> create_table(ExampleModel)

#now we can create some rows:
>>> em1 = ExampleModel.create(example_type=0, description="example1", created_at=datetime.now())
>>> em2 = ExampleModel.create(example_type=0, description="example2", created_at=datetime.now())
>>> em3 = ExampleModel.create(example_type=0, description="example3", created_at=datetime.now())
>>> em4 = ExampleModel.create(example_type=0, description="example4", created_at=datetime.now())
>>> em5 = ExampleModel.create(example_type=1, description="example5", created_at=datetime.now())
>>> em6 = ExampleModel.create(example_type=1, description="example6", created_at=datetime.now())
>>> em7 = ExampleModel.create(example_type=1, description="example7", created_at=datetime.now())
>>> em8 = ExampleModel.create(example_type=1, description="example8", created_at=datetime.now())
# Note: the UUID and DateTime columns will create uuid4 and datetime.now
# values automatically if we don't specify them when creating new rows

#and now we can run some queries against our table
>>> ExampleModel.objects.count()
8
>>> q = ExampleModel.objects(example_type=1)
>>> q.count()
4
>>> for instance in q:
>>>     print instance.description
example5
example6
example7
example8

#here we are applying additional filtering to an existing query
#query objects are immutable, so calling filter returns a new
#query object
>>> q2 = q.filter(example_id=em5.example_id)

>>> q2.count()
1
>>> for instance in q2:
>>>     print instance.description
example5

Contributing

If you'd like to contribute to cqlengine, please read the contributor guidelines

Description
RETIRED, further work has moved to Debian project infrastructure
Readme 7.8 MiB
Languages
Python 96.1%
Cython 2.2%
C 1.2%
reStructuredText 0.3%
PowerShell 0.2%