def get_cql_models(app, connection=None, keyspace=None):
from .models import DjangoCassandraModel<EOL>models = []<EOL>single_cassandra_connection = len(list(get_cassandra_connections())) == <NUM_LIT:1><EOL>is_default_connection = connection == DEFAULT_DB_ALIAS orsingle_cassandra_connection<EOL>for name, obj in inspect.getmembers(app):<EOL><INDENT>cql_model_types = (<EOL>cqlengine.models.Model,<EOL>DjangoCassandraModel<EOL>)<EOL>if (<EOL>inspect.isclass(obj) and issubclass(obj, cql_model_types) and<EOL>not obj.__abstract__<EOL>):<EOL><INDENT>if obj.__connection__ == connection or(obj.__connection__ is None and is_default_connection) orobj.__connection__ is None and obj.__keyspace__ is not None and obj.__keyspace__ == keyspace:<EOL><INDENT>models.append(obj)<EOL><DEDENT><DEDENT><DEDENT>return models<EOL>
:param app: django models module
:param connection: connection name
:param keyspace: keyspace
:return: list of all cassandra.cqlengine.Model within app that should be
synced to keyspace.