def run_query(self, query, user): connection = atsd_client.connect_url( self.url, self.configuration.get("username"), self.configuration.get("password"), verify=self.configuration.get("trust_certificate", False), timeout=self.configuration.get("timeout", 600), ) sql = SQLService(connection) query_id = str(uuid.uuid4()) try: logger.debug("SQL running query: %s", query) data = sql.query_with_params( query, {"outputFormat": "csv", "metadataFormat": "EMBED", "queryId": query_id}, ) columns, rows = generate_rows_and_columns(data) data = {"columns": columns, "rows": rows} json_data = json_dumps(data) error = None except SQLException as e: json_data = None error = e.content except (KeyboardInterrupt, InterruptException): sql.cancel_query(query_id) error = "Query cancelled by user." json_data = None return json_data, error
def run_query(self, query, user): connection = atsd_client.connect_url(self.url, self.configuration.get('username'), self.configuration.get('password'), verify=self.configuration.get('trust_certificate', False), timeout=self.configuration.get('timeout', 600)) sql = SQLService(connection) query_id = str(uuid.uuid4()) try: logger.debug("SQL running query: %s", query) data = sql.query_with_params(query, {'outputFormat': 'csv', 'metadataFormat': 'EMBED', 'queryId': query_id}) columns, rows = generate_rows_and_columns(data) data = {'columns': columns, 'rows': rows} json_data = json_dumps(data) error = None except SQLException as e: json_data = None error = e.content except (KeyboardInterrupt, InterruptException): sql.cancel_query(query_id) error = "Query cancelled by user." json_data = None return json_data, error
def run_query(self, query, user): connection = atsd_client.connect_url( self.url, self.configuration.get('username'), self.configuration.get('password'), verify=self.configuration.get('trust_certificate', False), timeout=self.configuration.get('timeout', 600)) sql = SQLService(connection) query_id = str(uuid.uuid4()) try: logger.debug("SQL running query: %s", query) data = sql.query_with_params( query, { 'outputFormat': 'csv', 'metadataFormat': 'EMBED', 'queryId': query_id }) columns, rows = generate_rows_and_columns(data) data = {'columns': columns, 'rows': rows} json_data = json_dumps(data) error = None except SQLException as e: json_data = None error = e.content except (KeyboardInterrupt, InterruptException): sql.cancel_query(query_id) error = "Query cancelled by user." json_data = None return json_data, error