MCPcopy Create free account
hub / github.com/apache/cassandra-python-driver / export_as_string

Method export_as_string

cassandra/metadata.py:1300–1326  ·  view source on GitHub ↗

Returns a string of CQL queries that can be used to recreate this table along with all indexes on it. The returned string is formatted to be human readable.

(self)

Source from the content-addressed store, hash-verified

1298 self.virtual = virtual
1299
1300 def export_as_string(self):
1301 """
1302 Returns a string of CQL queries that can be used to recreate this table
1303 along with all indexes on it. The returned string is formatted to
1304 be human readable.
1305 """
1306 if self._exc_info:
1307 import traceback
1308 ret = "/*\nWarning: Table %s.%s is incomplete because of an error processing metadata.\n" % \
1309 (self.keyspace_name, self.name)
1310 for line in traceback.format_exception(*self._exc_info):
1311 ret += line
1312 ret += "\nApproximate structure, for reference:\n(this should not be used to reproduce this schema)\n\n%s\n*/" % self._all_as_cql()
1313 elif not self.is_cql_compatible:
1314 # If we can't produce this table with CQL, comment inline
1315 ret = "/*\nWarning: Table %s.%s omitted because it has constructs not compatible with CQL (was created via legacy API).\n" % \
1316 (self.keyspace_name, self.name)
1317 ret += "\nApproximate structure, for reference:\n(this should not be used to reproduce this schema)\n\n%s\n*/" % self._all_as_cql()
1318 elif self.virtual:
1319 ret = ('/*\nWarning: Table {ks}.{tab} is a virtual table and cannot be recreated with CQL.\n'
1320 'Structure, for reference:\n'
1321 '{cql}\n*/').format(ks=self.keyspace_name, tab=self.name, cql=self._all_as_cql())
1322
1323 else:
1324 ret = self._all_as_cql()
1325
1326 return ret
1327
1328 def _all_as_cql(self):
1329 ret = self.as_cql_query(formatted=True)

Calls 1

_all_as_cqlMethod · 0.95