Django Cassandra DB
Project description
Django Cassandra Engine - the Cassandra backend for Django
All tools you need to start your journey with Apache Cassandra and Django Framework!
Features
- integration with latest
python-driver
and optionallydse-driver
from DataStax - working
flush
,migrate
,sync_cassandra
,inspectdb
anddbshell
commands - support for creating/destroying test database
- accepts all
Cqlengine
andcassandra.cluster.Cluster
connection options - automatic connection/disconnection handling
- works well along with relational databases (as secondary DB)
- storing sessions in Cassandra
- working django forms
- usable admin panel with Cassandra models
- support DataStax Astra cloud hosted Cassandra
Installation
Recommended installation:
pip install django-cassandra-db==0.0.2
Basic Usage
-
Add
django_cassandra_engine
toINSTALLED_APPS
in yoursettings.py
file:INSTALLED_APPS = ('django_cassandra_engine',) + INSTALLED_APPS
-
Change
DATABASES
setting: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 django_cassandra_engine.models import DjangoCassandraModel class ExampleModel(DjangoCassandraModel): 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_cassandra
-
Done!
Connect to Cassandra with a Cloud Config bundle
To connect to a hosted Cassandra cluster that provides a secure connection bundle (ex. DataStax Astra) change the DATABASES
setting of your settings.py:
DATABASES = {
'default': {
'ENGINE': 'django_cassandra_engine',
'NAME': 'db_name',
'TEST_NAME': 'db_name',
'USER': username,
'PASSWORD': password,
'OPTIONS': {
'connection': {
'cloud': {
'secure_connect_bundle': '/path/to/secure/bundle.zip'
},
}
}
}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-cassandra-db-0.0.2.tar.gz
(28.0 kB
view hashes)
Close
Hashes for django-cassandra-db-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 329b0697058ee3ddbb090ca7384f1e6d04a931b3b6e5988c610648d7a6af678b |
|
MD5 | ed8ef747b2f7c2ca6eb9a31965fdd712 |
|
BLAKE2b-256 | 1698ddc76c7ced405d6e814b46018332b26d7924832d6e4ce3750ce049de8c7a |