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-driverand optionallydse-driverfrom DataStax - working
flush,migrate,sync_cassandra,inspectdbanddbshellcommands - support for creating/destroying test database
- accepts all
Cqlengineandcassandra.cluster.Clusterconnection 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_enginetoINSTALLED_APPSin yoursettings.pyfile:INSTALLED_APPS = ('django_cassandra_engine',) + INSTALLED_APPS -
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 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 details)
File details
Details for the file django-cassandra-db-0.0.2.tar.gz.
File metadata
- Download URL: django-cassandra-db-0.0.2.tar.gz
- Upload date:
- Size: 28.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
329b0697058ee3ddbb090ca7384f1e6d04a931b3b6e5988c610648d7a6af678b
|
|
| MD5 |
ed8ef747b2f7c2ca6eb9a31965fdd712
|
|
| BLAKE2b-256 |
1698ddc76c7ced405d6e814b46018332b26d7924832d6e4ce3750ce049de8c7a
|