Django-scylla makes possible to connect your Django app to Cassandra or ScyllaDB and use native Django ORM as with any other relational database backend.
Discord: https://discord.gg/pxunMGmDNc
Help support ongoing development and maintenance by sponsoring Django Scylla.
Recommended installation:
pip install django-scylla
-
Add
django_scylla
toINSTALLED_APPS
in yoursettings.py
file:INSTALLED_APPS = ('django_scylla',) + INSTALLED_APPS
-
Change
DATABASES
setting:DATABASES = { 'default': { 'ENGINE': 'django_scylla', 'NAME': 'db', 'TEST_NAME': 'test_db', 'HOST': 'db1.example.com,db2.example.com,db3.example.com', 'OPTIONS': { 'replication': { 'strategy_class': ..., 'replication_factor': ... }, 'execution_profile': { 'load_balancing_policy': ..., 'retry_policy': ..., 'consistency_level': ..., 'serial_consistency_level': ..., 'request_timeout': ..., 'speculative_execution_policy': ... } 'connection': { # Full list of connection options can be found here: https://docs.datastax.com/en/developer/python-driver/3.26/api/cassandra/cluster/ 'cql_version': ..., 'protocol_version': ... 'compression': ..., 'consistency': ..., 'lazy_connect': ..., 'retry_connect': ..., } } } }
-
Define some model:
# myapp/models.py from django.db import models class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30)
-
Connect to ScyllaDB and create a keyspace.
-
Run
./manage.py makemigrations && ./manage.py migrate
-
Done!
Copyright (c) 2021-2022, Rafał Furmański.
All rights reserved. Licensed under MIT License.