Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6ae3a67

Browse files
committed
fix: return str instead of urllib3.HTTPResponse for InfluxDBClient.QueryAPI.query_raw
1 parent 1ec64b7 commit 6ae3a67

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

‎CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### Bug Fixes
44
1. [#601](https://github.com/influxdata/influxdb-client-python/pull/601): Use HTTResponse.headers to clear deprecation warning [urllib3]
5+
2. [#569](https://github.com/influxdata/influxdb-client-python/pull/569): Return `str` instead of `urllib3.HTTPResponse` for `InfluxDBClient.QueryAPI.query_raw`.
6+
57

68
### Documentation
79
1. [#566](https://github.com/influxdata/influxdb-client-python/pull/566): Fix Sphinx documentation build and add support `.readthedocs.yml` V2 configuration file

‎influxdb_client/client/query_api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from influxdb_client import Dialect
1010
from influxdb_client.client._base import _BaseQueryApi
1111
from influxdb_client.client.flux_table import FluxRecord, TableList, CSVIterator
12+
from influxdb_client.rest import _UTF_8_encoding
1213

1314

1415
class QueryOptions(object):
@@ -121,8 +122,8 @@ def query_raw(self, query: str, org=None, dialect=_BaseQueryApi.default_dialect,
121122
org = self._org_param(org)
122123
result = self._query_api.post_query(org=org, query=self._create_query(query, dialect, params), async_req=False,
123124
_preload_content=False)
124-
125-
return result
125+
raw_bytes=result.read()
126+
return raw_bytes.decode(_UTF_8_encoding)
126127

127128
def query(self, query: str, org=None, params: dict = None) -> TableList:
128129
"""Execute synchronous Flux query and return result as a :class:`~influxdb_client.client.flux_table.FluxTable` list.

‎tests/test_InfluxDBClient.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import codecs
21
import http.server
32
import json
43
import logging
@@ -346,7 +345,8 @@ def test_query_and_debug(self):
346345
self.assertIn("my-bucket", list(map(lambda record: record["name"], results[0].records)))
347346
# Query RAW
348347
results = self.client.query_api().query_raw("buckets()", "my-org")
349-
self.assertIn("my-bucket", codecs.decode(results.data))
348+
self.assertIn("my-bucket", results)
349+
self.assertTrue(isinstance(results, str))
350350
# Bucket API
351351
results = self.client.buckets_api().find_buckets()
352352
self.assertIn("my-bucket", list(map(lambda bucket: bucket.name, results.buckets)))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /