|
15 | 15 |
|
16 | 16 |
|
17 | 17 | class Cassandra(BaseQueryRunner):
|
18 |
| - noop_query = "SELECT * FROM system.compactions_in_progress" |
| 18 | + noop_query = "SELECT dateof(now()) FROM system.local" |
19 | 19 |
|
20 | 20 | @classmethod
|
21 | 21 | def enabled(cls):
|
@@ -53,23 +53,33 @@ def configuration_schema(cls):
|
53 | 53 | def type(cls):
|
54 | 54 | return "Cassandra"
|
55 | 55 |
|
56 |
| - def _get_tables(self, schema): |
| 56 | + def get_schema(self, get_stats=False): |
57 | 57 | query = """
|
58 |
| - select columnfamily_name from system.schema_columnfamilies where keyspace_name = '{}'; |
| 58 | + SELECT columnfamily_name, column_name FROM system.schema_columns where keyspace_name ='{}'; |
59 | 59 | """.format(self.configuration['keyspace'])
|
60 | 60 |
|
61 | 61 | results, error = self.run_query(query, None)
|
62 |
| - return results, error |
| 62 | + results = json.loads(results) |
| 63 | + |
| 64 | + schema = {} |
| 65 | + for row in results['rows']: |
| 66 | + table_name = row['columnfamily_name'] |
| 67 | + column_name = row['column_name'] |
| 68 | + if table_name not in schema: |
| 69 | + schema[table_name] = {'name': table_name, 'columns': []} |
| 70 | + schema[table_name]['columns'].append(column_name) |
| 71 | + |
| 72 | + return schema.values() |
63 | 73 |
|
64 | 74 | def run_query(self, query, user):
|
65 | 75 | connection = None
|
66 | 76 | try:
|
67 | 77 | if self.configuration.get('username', '') and self.configuration.get('password', ''):
|
68 | 78 | auth_provider = PlainTextAuthProvider(username='{}'.format(self.configuration.get('username', '')),
|
69 | 79 | password='{}'.format(self.configuration.get('password', '')))
|
70 |
| - connection = Cluster([self.configuration.get('host', '')], auth_provider=auth_provider) |
| 80 | + connection = Cluster([self.configuration.get('host', '')], auth_provider=auth_provider, protocol_version=3) |
71 | 81 | else:
|
72 |
| - connection = Cluster([self.configuration.get('host', '')]) |
| 82 | + connection = Cluster([self.configuration.get('host', '')], protocol_version=3) |
73 | 83 |
|
74 | 84 | session = connection.connect()
|
75 | 85 | session.set_keyspace(self.configuration['keyspace'])
|
|
0 commit comments