Movatterモバイル変換


[0]ホーム

URL:


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

fix: returnstr instead ofurllib3.HTTPResponse for `InfluxDBClie…#606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jules-ch wants to merge2 commits intoinfluxdata:master
base:master
Choose a base branch
Loading
fromjules-ch:569-queryraw-return-type
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletionsCHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
## 1.39.0 [unreleased]

### Breaking Changes

1. [#569](https://github.com/influxdata/influxdb-client-python/pull/569): Return `str` instead of `urllib3.HTTPResponse` for `InfluxDBClient.QueryAPI.query_raw`.

This fixes `InfluxDBClient.query_raw` that returned the wrong type based on the documentation.

The async version `InfluxDBClientAsync` is not affected.

To make your code compatible with this version, you can remove the step of retrieving the response content:

```diff
from influxdb_client.client import InfluxDBClient

with InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org") as client:
query = "..."
result = client.query_raw(query=query)
- content = result.data.decode("utf8")
+ content = result
```


## 1.38.0 [2023-10-02]

### Bug Fixes
1. [#601](https://github.com/influxdata/influxdb-client-python/pull/601): Use HTTResponse.headers to clear deprecation warning [urllib3]
1. [#610](https://github.com/influxdata/influxdb-client-python/pull/601): Use iloc to clear deprecation warning


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

Expand Down
5 changes: 3 additions & 2 deletionsinfluxdb_client/client/query_api.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@
from influxdb_client import Dialect
from influxdb_client.client._base import _BaseQueryApi
from influxdb_client.client.flux_table import FluxRecord, TableList, CSVIterator
from influxdb_client.rest import _UTF_8_encoding


class QueryOptions(object):
Expand DownExpand Up@@ -121,8 +122,8 @@ def query_raw(self, query: str, org=None, dialect=_BaseQueryApi.default_dialect,
org = self._org_param(org)
result = self._query_api.post_query(org=org, query=self._create_query(query, dialect, params), async_req=False,
_preload_content=False)

returnresult
raw_bytes = result.data
returnraw_bytes.decode(_UTF_8_encoding)

def query(self, query: str, org=None, params: dict = None) -> TableList:
"""Execute synchronous Flux query and return result as a :class:`~influxdb_client.client.flux_table.FluxTable` list.
Expand Down
4 changes: 2 additions & 2 deletionstests/test_InfluxDBClient.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
import codecs
import http.server
import json
import logging
Expand DownExpand Up@@ -346,7 +345,8 @@ def test_query_and_debug(self):
self.assertIn("my-bucket", list(map(lambda record: record["name"], results[0].records)))
# Query RAW
results = self.client.query_api().query_raw("buckets()", "my-org")
self.assertIn("my-bucket", codecs.decode(results.data))
self.assertIn("my-bucket", results)
self.assertTrue(isinstance(results, str))
# Bucket API
results = self.client.buckets_api().find_buckets()
self.assertIn("my-bucket", list(map(lambda bucket: bucket.name, results.buckets)))
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp