# Path: django_cassandra_engine/utils.py
# def get_default_cassandra_connection():
#     """
#     Return first default cassandra connection
#     :return:
#     """
#     for alias, conn in get_cassandra_connections():
#         if conn.connection.default:
#             return alias, conn
# 
#     return list(get_cassandra_connections())[0]
# 
# Path: django_cassandra_engine/compat.py



import logging
from cassandra.cqlengine.connection import set_default_connection
from django.db.backends.base.creation import BaseDatabaseCreation
from django_cassandra_engine.utils import get_default_cassandra_connection
from ..compat import create_keyspace_simple, drop_keyspace
        from django.conf import settings
        from django.core.management import call_command
        settings.DATABASES[self.connection.alias]["NAME"] = test_database_name
        self.connection.settings_dict["NAME"] = test_database_name

        self.connection.reconnect()
        set_default_connection(default_alias)

        # Report syncdb messages at one level lower than that requested.
        # This ensures we don't get flooded with messages during testing
        # (unless you really ask to be flooded)
        call_command(
            "sync_cassandra",
            verbosity=max(verbosity - 1, 0),
            database=self.connection.alias,
        )

        # restore the original connection options
        if not connection_options_copy.get("schema_metadata_enabled", True):
            logger.info(
                "Disabling metadata on %s" % self.connection.settings_dict["NAME"]
            )
            options["connection"]["schema_metadata_enabled"] = connection_options_copy[
                "schema_metadata_enabled"
            ]
            self.connection.reconnect()
            set_default_connection(default_alias)

        return test_database_name

    def _destroy_test_db(self, test_database_name, verbosity=1, **kwargs):


# Path: django_cassandra_engine/utils.py
# def get_default_cassandra_connection():
#     """
#     Return first default cassandra connection
#     :return:
#     """
#     for alias, conn in get_cassandra_connections():
#         if conn.connection.default:
#             return alias, conn
# 
#     return list(get_cassandra_connections())[0]
# 
# Path: django_cassandra_engine/compat.py



# Path: django_cassandra_engine/base/creation.py
import logging
from cassandra.cqlengine.connection import set_default_connection
from django.db.backends.base.creation import BaseDatabaseCreation
from django_cassandra_engine.utils import get_default_cassandra_connection
from ..compat import create_keyspace_simple, drop_keyspace
        from django.conf import settings
        from django.core.management import call_command

        settings.DATABASES[self.connection.alias]["NAME"] = test_database_name
        self.connection.settings_dict["NAME"] = test_database_name

        self.connection.reconnect()
        set_default_connection(default_alias)

        # Report syncdb messages at one level lower than that requested.
        # This ensures we don't get flooded with messages during testing
        # (unless you really ask to be flooded)
        call_command(
            "sync_cassandra",
            verbosity=max(verbosity - 1, 0),
            database=self.connection.alias,
        )

        # restore the original connection options
        if not connection_options_copy.get("schema_metadata_enabled", True):
            logger.info(
                "Disabling metadata on %s" % self.connection.settings_dict["NAME"]
            )
            options["connection"]["schema_metadata_enabled"] = connection_options_copy[
                "schema_metadata_enabled"
            ]
            self.connection.reconnect()
            set_default_connection(default_alias)

        return test_database_name

    def _destroy_test_db(self, test_database_name, verbosity=1, **kwargs):


        drop_keyspace(test_database_name, connections=[self.connection.alias])