|
37 | 37 | schema_columnfamilies = NamedTable('system', 'schema_columnfamilies')
|
38 | 38 |
|
39 | 39 |
|
40 |
| -def create_keyspace(name, strategy_class, replication_factor, durable_writes=True, **replication_values): |
41 |
| - """ |
42 |
| - *Deprecated - use :func:`create_keyspace_simple` or :func:`create_keyspace_network_topology` instead* |
43 |
| -
|
44 |
| - Creates a keyspace |
45 |
| -
|
46 |
| - If the keyspace already exists, it will not be modified. |
47 |
| -
|
48 |
| - **This function should be used with caution, especially in production environments. |
49 |
| - Take care to execute schema modifications in a single context (i.e. not concurrently with other clients).** |
50 |
| -
|
51 |
| - *There are plans to guard schema-modifying functions with an environment-driven conditional.* |
52 |
| -
|
53 |
| - :param str name: name of keyspace to create |
54 |
| - :param str strategy_class: keyspace replication strategy class (:attr:`~.SimpleStrategy` or :attr:`~.NetworkTopologyStrategy` |
55 |
| - :param int replication_factor: keyspace replication factor, used with :attr:`~.SimpleStrategy` |
56 |
| - :param bool durable_writes: Write log is bypassed if set to False |
57 |
| - :param \*\*replication_values: Additional values to ad to the replication options map |
58 |
| - """ |
59 |
| - if not _allow_schema_modification(): |
60 |
| - return |
61 |
| - |
62 |
| - msg = "Deprecated. Use create_keyspace_simple or create_keyspace_network_topology instead" |
63 |
| - warnings.warn(msg, DeprecationWarning) |
64 |
| - log.warning(msg) |
65 |
| - |
66 |
| - cluster = get_cluster() |
67 |
| - |
68 |
| - if name not in cluster.metadata.keyspaces: |
69 |
| - # try the 1.2 method |
70 |
| - replication_map = { |
71 |
| - 'class': strategy_class, |
72 |
| - 'replication_factor': replication_factor |
73 |
| - } |
74 |
| - replication_map.update(replication_values) |
75 |
| - if strategy_class.lower() != 'simplestrategy': |
76 |
| - # Although the Cassandra documentation states for `replication_factor` |
77 |
| - # that it is "Required if class is SimpleStrategy; otherwise, |
78 |
| - # not used." we get an error if it is present. |
79 |
| - replication_map.pop('replication_factor', None) |
80 |
| - |
81 |
| - query = """ |
82 |
| - CREATE KEYSPACE {0} |
83 |
| - WITH REPLICATION = {1} |
84 |
| - """.format(metadata.protect_name(name), json.dumps(replication_map).replace('"', "'")) |
85 |
| - |
86 |
| - if strategy_class != 'SimpleStrategy': |
87 |
| - query += " AND DURABLE_WRITES = {0}".format('true' if durable_writes else 'false') |
88 |
| - |
89 |
| - execute(query) |
90 |
| - |
91 |
| - |
92 | 40 | def create_keyspace_simple(name, replication_factor, durable_writes=True):
|
93 | 41 | """
|
94 | 42 | Creates a keyspace with SimpleStrategy for replica placement
|
@@ -140,13 +88,6 @@ def _create_keyspace(name, durable_writes, strategy_class, strategy_options):
|
140 | 88 | log.info("Not creating keyspace %s because it already exists", name)
|
141 | 89 |
|
142 | 90 |
|
143 |
| -def delete_keyspace(name): |
144 |
| - msg = "Deprecated. Use drop_keyspace instead" |
145 |
| - warnings.warn(msg, DeprecationWarning) |
146 |
| - log.warning(msg) |
147 |
| - drop_keyspace(name) |
148 |
| - |
149 |
| - |
150 | 91 | def drop_keyspace(name):
|
151 | 92 | """
|
152 | 93 | Drops a keyspace, if it exists.
|
|
0 commit comments