I am trying to set a django app and connect it to AWS Keyspaces. Trying to do it using django-cassandra-engine.
I'm currently using this setup in the settings, but it's not working.
ssl_context = SSLContext(PROTOCOL_TLSv1_2)
ssl_context.load_verify_locations('/Users/amit/sf-class2-root.crt')
ssl_context.verify_mode = CERT_REQUIRED
DATABASES = {
'default': {
'ENGINE': 'django_cassandra_engine',
'NAME': 'Keyspace Name',
'HOST': 'Cluster()',
'connection': {
'port': 9142,
'contact_points': ['cassandra.us-east-1.amazonaws.com'],
'ssl_context': ssl_context,
'auth_provider': PlainTextAuthProvider(username='USERNAME',password='PASSWORD')
}
}
}
Error:
File "/Users/amit/workspace/eventHandler/venv/lib/python3.9/site-packages/django_cassandra_engine/connection.py", line 78, in register
connection.get_connection(name=self.alias)
File "/Users/amit/workspace/eventHandler/venv/lib/python3.9/site-packages/cassandra/cqlengine/connection.py", line 247, in get_connection raise CQLEngineException("Connection name '{0}' doesn't exist in the registry.".format(name)) cassandra.cqlengine.CQLEngineException: Connection name 'default' doesn't exist in the registry.
Figured out:-
DATABASES = {
'default': {
'ENGINE': 'django_cassandra_engine',
'NAME': 'KEYSPACE_NAME',
'HOST': 'cassandra.us-east-1.amazonaws.com',
'OPTIONS': {
'replication': {
'strategy_class': 'SimpleStrategy',
'replication_factor': 1
},
'connection': {
'port': 9142,
'ssl_context': ssl_context,
'auth_provider': PlainTextAuthProvider(username='USERNAME',
password='PASSWORD')
}
}
}
}