# 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

        # If using django-nose, its runner has already set the db name
        # to test_*, so restore it here so that all the models for the
        # live keyspace can be found.
        self.connection.connection.keyspace = self.connection.settings_dict["NAME"]
        test_database_name = self._get_test_db_name()
        # Set all models keyspace to the test keyspace
        self.set_models_keyspace(test_database_name)

        if verbosity >= 1:
            test_db_repr = ""
            if verbosity >= 2:
                test_db_repr = " ('%s')" % test_database_name
            logger.info(
                "Creating test database for alias '%s'%s..."
                % (self.connection.alias, test_db_repr)
            )

        options = self.connection.settings_dict.get("OPTIONS", {})

        # temporarily enable schema metadata for sync_cassandra
        connection_options_copy = options.get("connection", {}).copy()
        if not connection_options_copy.get("schema_metadata_enabled", True):
            options["connection"]["schema_metadata_enabled"] = True
            self.connection.reconnect()
            set_default_connection(default_alias)

        replication_opts = options.get("replication", {})
        replication_factor = replication_opts.pop("replication_factor", 1)


# 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


        # If using django-nose, its runner has already set the db name
        # to test_*, so restore it here so that all the models for the
        # live keyspace can be found.
        self.connection.connection.keyspace = self.connection.settings_dict["NAME"]
        test_database_name = self._get_test_db_name()
        # Set all models keyspace to the test keyspace
        self.set_models_keyspace(test_database_name)

        if verbosity >= 1:
            test_db_repr = ""
            if verbosity >= 2:
                test_db_repr = " ('%s')" % test_database_name
            logger.info(
                "Creating test database for alias '%s'%s..."
                % (self.connection.alias, test_db_repr)
            )

        options = self.connection.settings_dict.get("OPTIONS", {})

        # temporarily enable schema metadata for sync_cassandra
        connection_options_copy = options.get("connection", {}).copy()
        if not connection_options_copy.get("schema_metadata_enabled", True):
            options["connection"]["schema_metadata_enabled"] = True
            self.connection.reconnect()
            set_default_connection(default_alias)

        replication_opts = options.get("replication", {})
        replication_factor = replication_opts.pop("replication_factor", 1)


        create_keyspace_simple(