Drops a keyspace, if it exists. *There are plans to guard schema-modifying functions with an environment-driven conditional.* **This function should be used with caution, especially in production environments. Take care to execute schema modifications in a single context (i.e. not
(name, connections=None)
| 121 | |
| 122 | |
| 123 | def drop_keyspace(name, connections=None): |
| 124 | """ |
| 125 | Drops a keyspace, if it exists. |
| 126 | |
| 127 | *There are plans to guard schema-modifying functions with an environment-driven conditional.* |
| 128 | |
| 129 | **This function should be used with caution, especially in production environments. |
| 130 | Take care to execute schema modifications in a single context (i.e. not concurrently with other clients).** |
| 131 | |
| 132 | :param str name: name of keyspace to drop |
| 133 | :param list connections: List of connection names |
| 134 | """ |
| 135 | if not _allow_schema_modification(): |
| 136 | return |
| 137 | |
| 138 | if connections: |
| 139 | if not isinstance(connections, (list, tuple)): |
| 140 | raise ValueError('Connections must be a list or a tuple.') |
| 141 | |
| 142 | def _drop_keyspace(name, connection=None): |
| 143 | cluster = get_cluster(connection) |
| 144 | if name in cluster.metadata.keyspaces: |
| 145 | execute("DROP KEYSPACE {0}".format(metadata.protect_name(name)), connection=connection) |
| 146 | |
| 147 | if connections: |
| 148 | for connection in connections: |
| 149 | _drop_keyspace(name, connection) |
| 150 | else: |
| 151 | _drop_keyspace(name) |
| 152 | |
| 153 | def _get_index_name_by_column(table, column_name): |
| 154 | """ |