(name, durable_writes, strategy_class, strategy_options, connections=None)
| 96 | |
| 97 | |
| 98 | def _create_keyspace(name, durable_writes, strategy_class, strategy_options, connections=None): |
| 99 | if not _allow_schema_modification(): |
| 100 | return |
| 101 | |
| 102 | if connections: |
| 103 | if not isinstance(connections, (list, tuple)): |
| 104 | raise ValueError('Connections must be a list or a tuple.') |
| 105 | |
| 106 | def __create_keyspace(name, durable_writes, strategy_class, strategy_options, connection=None): |
| 107 | cluster = get_cluster(connection) |
| 108 | |
| 109 | if name not in cluster.metadata.keyspaces: |
| 110 | log.info(format_log_context("Creating keyspace %s", connection=connection), name) |
| 111 | ks_meta = metadata.KeyspaceMetadata(name, durable_writes, strategy_class, strategy_options) |
| 112 | execute(ks_meta.as_cql_query(), connection=connection) |
| 113 | else: |
| 114 | log.info(format_log_context("Not creating keyspace %s because it already exists", connection=connection), name) |
| 115 | |
| 116 | if connections: |
| 117 | for connection in connections: |
| 118 | __create_keyspace(name, durable_writes, strategy_class, strategy_options, connection=connection) |
| 119 | else: |
| 120 | __create_keyspace(name, durable_writes, strategy_class, strategy_options) |
| 121 | |
| 122 | |
| 123 | def drop_keyspace(name, connections=None): |
no test coverage detected