# Path: django_cassandra_engine/utils.py
# def get_cassandra_connections():
#     """
#     :return: List of tuples (db_alias, connection) for all cassandra
#     connections in DATABASES dict.
#     """
#     from django.db import connections
# 
#     for alias in connections:
#         engine = connections[alias].settings_dict.get("ENGINE", "")
#         if engine == "django_cassandra_engine":
#             yield alias, connections[alias]
# 
# Path: django_cassandra_engine/compat.py



from django_cassandra_engine.utils import get_cassandra_connections
from .compat import (
    Cluster,
    CQLEngineException,
    PlainTextAuthProvider,
    Session,
    connection,
)
                from cassandra.cqlengine import models
        self.options = options.get("OPTIONS", {})
        self.cluster_options = self.options.get("connection", {})
        self.session_options = self.options.get("session", {})
        self.connection_options = {
            "lazy_connect": self.cluster_options.pop("lazy_connect", False),
            "retry_connect": self.cluster_options.pop("retry_connect", False),
            "consistency": self.cluster_options.pop("consistency", None),
        }
        if self.user and self.password and "auth_provider" not in self.cluster_options:
            self.cluster_options["auth_provider"] = PlainTextAuthProvider(
                username=self.user, password=self.password
            )

        self.default = (
            alias == "default"
            or len(list(get_cassandra_connections())) == 1
            or self.cluster_options.pop("default", False)
        )

        self.register()

    def register(self):
        try:
            connection.get_connection(name=self.alias)
        except CQLEngineException:
            if self.default:

                models.DEFAULT_KEYSPACE = self.keyspace

            for option, value in self.session_options.items():

# Path: django_cassandra_engine/utils.py
# def get_cassandra_connections():
#     """
#     :return: List of tuples (db_alias, connection) for all cassandra
#     connections in DATABASES dict.
#     """
#     from django.db import connections
# 
#     for alias in connections:
#         engine = connections[alias].settings_dict.get("ENGINE", "")
#         if engine == "django_cassandra_engine":
#             yield alias, connections[alias]
# 
# Path: django_cassandra_engine/compat.py



# Path: django_cassandra_engine/connection.py
from django_cassandra_engine.utils import get_cassandra_connections
from .compat import (
    Cluster,
    CQLEngineException,
    PlainTextAuthProvider,
    Session,
    connection,
)
                from cassandra.cqlengine import models

        self.options = options.get("OPTIONS", {})
        self.cluster_options = self.options.get("connection", {})
        self.session_options = self.options.get("session", {})
        self.connection_options = {
            "lazy_connect": self.cluster_options.pop("lazy_connect", False),
            "retry_connect": self.cluster_options.pop("retry_connect", False),
            "consistency": self.cluster_options.pop("consistency", None),
        }
        if self.user and self.password and "auth_provider" not in self.cluster_options:
            self.cluster_options["auth_provider"] = PlainTextAuthProvider(
                username=self.user, password=self.password
            )

        self.default = (
            alias == "default"
            or len(list(get_cassandra_connections())) == 1
            or self.cluster_options.pop("default", False)
        )

        self.register()

    def register(self):
        try:
            connection.get_connection(name=self.alias)
        except CQLEngineException:
            if self.default:

                models.DEFAULT_KEYSPACE = self.keyspace

            for option, value in self.session_options.items():

                setattr(Session, option, value)