Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple cassandra configurations #144

Open
akap97 opened this issue Mar 9, 2021 · 5 comments
Open

Multiple cassandra configurations #144

akap97 opened this issue Mar 9, 2021 · 5 comments

Comments

@akap97
Copy link

akap97 commented Mar 9, 2021

I have multiple cassandra configurations.
my settings.py is as follows:
DATABASES = { 'db1': { 'ENGINE': 'django_cassandra_engine', 'NAME': 'keyspace1', 'HOST': 'host1', 'PORT': port1, 'OPTIONS': { 'replication': { 'strategy_class': 'SimpleStrategy', 'replication_factor': 'factor1' } } } 'db2': { 'ENGINE': 'django_cassandra_engine', 'NAME': 'keyspace2', 'HOST': 'host2', 'PORT': port2, 'OPTIONS': { 'replication': { 'strategy_class': 'SimpleStrategy', 'replication_factor': 'factor2' } } } } ...and so on
How to programmatically connect to different cassandra configurations when querying cassandra models. DB router is not working with cassandra.

@r4fek
Copy link
Owner

r4fek commented Mar 9, 2021

For example Model.objects.using('db2').filter(...)

@akap97
Copy link
Author

akap97 commented Mar 9, 2021

For example Model.objects.using('db2').filter(...)

It is giving me
cassandra.cqlengine.CQLEngineException: Connection name '<object object at 0x7fd0fe35d0a0>' doesn't exist in the registry.

@akap97
Copy link
Author

akap97 commented Mar 9, 2021

For example Model.objects.using('db2').filter(...)

It is giving me:
cassandra.cqlengine.CQLEngineException: Connection name '<object object at 0x7fd0fe35d0a0>' doesn't exist in the registry.

@r4fek
Copy link
Owner

r4fek commented Mar 9, 2021

@akap97
Copy link
Author

akap97 commented Mar 9, 2021

Please take a look at following example from testproject: https://github.com/r4fek/django-cassandra-engine/blob/f6d74090d560c7e9d86877051bb693d342de10b7/testproject/multiapp/models.py

I am creating models by inheriting DjangoCassandraModel not models.Model(as in example project). DjangoCassandraModel does not have __connection__ property. Also is it possible to specify the connection while hitting the APIs and not in the model itself?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants