django-cassandra-engine is a database wrapper for Django Framework. It uses the latest cassandra-driver while primarily utilizing Cqlengine which is currently the best Cassandra CQL 3 Object Mapper for Python and was integrated into cassandra-driver.
| License: | 2-clause BSD |
|---|---|
| Keywords: | django, cassandra, orm, nosql, database, python |
| URL (pypi): | django-cassandra-engine |
Recommended installation:
pip install django-cassandra-engine
Add django-cassandra-engine to
INSTALLED_APPSin your settings.py file:INSTALLED_APPS = ('django_cassandra_engine',) + INSTALLED_APPS
IMPORTANT: This app should be the first app on INSTALLED_APPS list.
Also change
DATABASESsetting:DATABASES = { 'default': { 'ENGINE': 'django_cassandra_engine', 'NAME': 'db', 'TEST_NAME': 'test_db', 'HOST': 'db1.example.com,db2.example.com', 'OPTIONS': { 'replication': { 'strategy_class': 'SimpleStrategy', 'replication_factor': 1 } } } }Define some model:
# myapp/models.py import uuid from cassandra.cqlengine import columns from cassandra.cqlengine.models import Model class ExampleModel(Model): example_id = columns.UUID(primary_key=True, default=uuid.uuid4) example_type = columns.Integer(index=True) created_at = columns.DateTime() description = columns.Text(required=False)Run
./manage.py sync_cassandraDone!
You can find documentation here.