influxdb3-python 0.15.0__tar.gz → 0.17.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- influxdb3_python-0.17.0/Examples/timeouts.py +83 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/PKG-INFO +80 -6
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/README.md +77 -5
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb3_python.egg-info/PKG-INFO +80 -6
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb3_python.egg-info/SOURCES.txt +2 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb3_python.egg-info/requires.txt +2 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/__init__.py +189 -10
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/query/query_api.py +52 -15
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/version.py +1 -1
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/_sync/api_client.py +1 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/client/write_api.py +119 -72
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/service/write_service.py +75 -11
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/setup.py +7 -1
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/tests/test_api_client.py +44 -0
- influxdb3_python-0.17.0/tests/test_flush.py +86 -0
- influxdb3_python-0.17.0/tests/test_influxdb_client_3.py +613 -0
- influxdb3_python-0.17.0/tests/test_influxdb_client_3_integration.py +584 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/tests/test_polars.py +2 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/tests/test_query.py +35 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/tests/test_write_local_server.py +86 -0
- influxdb3_python-0.15.0/tests/test_influxdb_client_3.py +0 -289
- influxdb3_python-0.15.0/tests/test_influxdb_client_3_integration.py +0 -249
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/Examples/__init__.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/Examples/basic_ssl_example.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/Examples/batching_example.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/Examples/cloud_dedicated_query.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/Examples/cloud_dedicated_write.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/Examples/config.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/Examples/flight_options_example.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/Examples/handle_http_error.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/Examples/handle_query_error.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/Examples/pandas_write.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/Examples/query_async.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/Examples/query_type.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/LICENSE +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb3_python.egg-info/dependency_links.txt +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb3_python.egg-info/top_level.txt +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/exceptions/__init__.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/exceptions/exceptions.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/py.typed +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/query/__init__.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/read_file.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/__init__.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/_sync/__init__.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/_sync/rest.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/client/__init__.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/client/_base.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/client/influxdb_client.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/client/logging_handler.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/client/util/__init__.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/client/util/date_utils.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/client/util/date_utils_pandas.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/client/util/helpers.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/client/util/multiprocessing_helper.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/client/warnings.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/client/write/__init__.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/client/write/dataframe_serializer.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/client/write/point.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/client/write/polars_dataframe_serializer.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/client/write/retry.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/configuration.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/domain/__init__.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/domain/write_precision.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/domain/write_precision_converter.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/extras.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/rest.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/service/__init__.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/service/_base_service.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/service/signin_service.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/influxdb_client_3/write_client/service/signout_service.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/pyproject.toml +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/setup.cfg +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/tests/test_dataframe_serializer.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/tests/test_date_helper.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/tests/test_deep_merge.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/tests/test_merge_options.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/tests/test_point.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/tests/test_write_file.py +0 -0
- {influxdb3_python-0.15.0 → influxdb3_python-0.17.0}/tests/test_write_precision_converter.py +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import sys
|
|
3
|
+
import time
|
|
4
|
+
|
|
5
|
+
from influxdb_client_3 import InfluxDBClient3, write_client_options
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
This example shows how to set query and write timeouts.
|
|
9
|
+
They can be set directly using arguments (write_timeout, query_timeout) in the client constructor.
|
|
10
|
+
They can also be overridden in write and query calls.
|
|
11
|
+
|
|
12
|
+
To trigger timeout and deadline expired exceptions, reset the timeout values in the examples or
|
|
13
|
+
supply new values as command line parameters.
|
|
14
|
+
|
|
15
|
+
Be sure to update the host, token a database values below, before running this example.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
DEFAULT_WRITE_TIMEOUT = 30_000 # in milliseconds
|
|
19
|
+
DEFAULT_QUERY_TIMEOUT = 120_000 # in milliseconds
|
|
20
|
+
DEFAULT_HOST = 'http://localhost:8181'
|
|
21
|
+
DEFAULT_TOKEN = 'my-token'
|
|
22
|
+
DEFAULT_DATABASE = 'test-data'
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def handle_write_error_cb(rd, rt, rx):
|
|
26
|
+
print(f"Got a write error: {rd}, {rt}, {rx}")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def main(w_to: int, q_to: int) -> None:
|
|
30
|
+
print(f"main {w_to}, {q_to}")
|
|
31
|
+
lp_data = "timeout_example,location=terra fVal=3.14,iVal=42i"
|
|
32
|
+
with InfluxDBClient3(
|
|
33
|
+
host=DEFAULT_HOST,
|
|
34
|
+
token=DEFAULT_TOKEN,
|
|
35
|
+
database=DEFAULT_DATABASE,
|
|
36
|
+
write_timeout=w_to,
|
|
37
|
+
query_timeout=q_to,
|
|
38
|
+
write_client_options=write_client_options(
|
|
39
|
+
error_handler=handle_write_error_cb
|
|
40
|
+
)
|
|
41
|
+
) as client:
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
# write with write timeout set in client
|
|
45
|
+
client.write(record=lp_data)
|
|
46
|
+
print("First write OK.")
|
|
47
|
+
time.sleep(1)
|
|
48
|
+
|
|
49
|
+
# write overriding client internal write timeout
|
|
50
|
+
# to force an exception try a _request_timeout value like 1 ms
|
|
51
|
+
client.write(record=lp_data, _request_timeout=9_000)
|
|
52
|
+
print("Second write OK.")
|
|
53
|
+
time.sleep(1)
|
|
54
|
+
except Exception as e:
|
|
55
|
+
print(f"Got exception on write: {e}")
|
|
56
|
+
|
|
57
|
+
sql = "SELECT * FROM timeout_example"
|
|
58
|
+
|
|
59
|
+
try:
|
|
60
|
+
# query using query timeout set in client
|
|
61
|
+
result = client.query(sql)
|
|
62
|
+
print("\nFirst query result\n", result)
|
|
63
|
+
time.sleep(1)
|
|
64
|
+
|
|
65
|
+
# query overriding client internal query timeout
|
|
66
|
+
# To force an exception try a timeout value like 0.001 seconds
|
|
67
|
+
result = client.query(sql, timeout=3.0)
|
|
68
|
+
print("\nSecond query result\n", result)
|
|
69
|
+
except Exception as e:
|
|
70
|
+
print(f"Got exception on query: {e}")
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# To force timeout errors supply the corresponding command line arguments
|
|
74
|
+
if __name__ == "__main__":
|
|
75
|
+
w_ct = DEFAULT_WRITE_TIMEOUT
|
|
76
|
+
q_ct = DEFAULT_QUERY_TIMEOUT
|
|
77
|
+
for index, arg in enumerate(sys.argv):
|
|
78
|
+
if index == 1:
|
|
79
|
+
w_ct = int(arg)
|
|
80
|
+
if index == 2:
|
|
81
|
+
q_ct = int(arg)
|
|
82
|
+
|
|
83
|
+
main(w_ct, q_ct)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: influxdb3-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.17.0
|
|
4
4
|
Summary: Community Python client for InfluxDB 3.0
|
|
5
5
|
Home-page: https://github.com/InfluxCommunity/influxdb3-python
|
|
6
6
|
Author: InfluxData
|
|
@@ -33,6 +33,8 @@ Provides-Extra: test
|
|
|
33
33
|
Requires-Dist: pytest; extra == "test"
|
|
34
34
|
Requires-Dist: pytest-cov; extra == "test"
|
|
35
35
|
Requires-Dist: pytest-httpserver; extra == "test"
|
|
36
|
+
Requires-Dist: h2<5.0.0,>=4.0.0; extra == "test"
|
|
37
|
+
Requires-Dist: cryptography>=3.4.0; extra == "test"
|
|
36
38
|
Dynamic: author
|
|
37
39
|
Dynamic: author-email
|
|
38
40
|
Dynamic: classifier
|
|
@@ -181,14 +183,46 @@ print(f'DONE writing from csv in {callback.write_count} batch(es)')
|
|
|
181
183
|
|
|
182
184
|
```
|
|
183
185
|
|
|
184
|
-
### Pandas
|
|
186
|
+
### Pandas DataFrame
|
|
185
187
|
```python
|
|
186
|
-
|
|
188
|
+
import pandas as pd
|
|
189
|
+
|
|
190
|
+
# Create a DataFrame with a timestamp column
|
|
191
|
+
df = pd.DataFrame({
|
|
192
|
+
'time': pd.to_datetime(['2024-01-01', '2024-01-02', '2024-01-03']),
|
|
193
|
+
'trainer': ['Ash', 'Misty', 'Brock'],
|
|
194
|
+
'pokemon_id': [25, 120, 74],
|
|
195
|
+
'pokemon_name': ['Pikachu', 'Staryu', 'Geodude']
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
# Write the DataFrame - timestamp_column is required for consistency
|
|
199
|
+
client.write_dataframe(
|
|
200
|
+
df,
|
|
201
|
+
measurement='caught',
|
|
202
|
+
timestamp_column='time',
|
|
203
|
+
tags=['trainer', 'pokemon_id']
|
|
204
|
+
)
|
|
187
205
|
```
|
|
188
206
|
|
|
189
|
-
### Polars
|
|
207
|
+
### Polars DataFrame
|
|
190
208
|
```python
|
|
191
|
-
|
|
209
|
+
import polars as pl
|
|
210
|
+
|
|
211
|
+
# Create a DataFrame with a timestamp column
|
|
212
|
+
df = pl.DataFrame({
|
|
213
|
+
'time': ['2024-01-01T00:00:00Z', '2024-01-02T00:00:00Z'],
|
|
214
|
+
'trainer': ['Ash', 'Misty'],
|
|
215
|
+
'pokemon_id': [25, 120],
|
|
216
|
+
'pokemon_name': ['Pikachu', 'Staryu']
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
# Write the DataFrame - same API works for both pandas and polars
|
|
220
|
+
client.write_dataframe(
|
|
221
|
+
df,
|
|
222
|
+
measurement='caught',
|
|
223
|
+
timestamp_column='time',
|
|
224
|
+
tags=['trainer', 'pokemon_id']
|
|
225
|
+
)
|
|
192
226
|
```
|
|
193
227
|
|
|
194
228
|
## Querying
|
|
@@ -201,6 +235,15 @@ table = reader.read_all()
|
|
|
201
235
|
print(table.to_pandas().to_markdown())
|
|
202
236
|
```
|
|
203
237
|
|
|
238
|
+
### Querying to DataFrame
|
|
239
|
+
```python
|
|
240
|
+
# Query directly to a pandas DataFrame (default)
|
|
241
|
+
df = client.query_dataframe("SELECT * FROM caught WHERE trainer = 'Ash'")
|
|
242
|
+
|
|
243
|
+
# Query to a polars DataFrame
|
|
244
|
+
df = client.query_dataframe("SELECT * FROM caught", frame_type="polars")
|
|
245
|
+
```
|
|
246
|
+
|
|
204
247
|
### Querying with influxql
|
|
205
248
|
```python
|
|
206
249
|
query = "select * from measurement"
|
|
@@ -209,6 +252,34 @@ table = reader.read_all()
|
|
|
209
252
|
print(table.to_pandas().to_markdown())
|
|
210
253
|
```
|
|
211
254
|
|
|
255
|
+
### gRPC compression
|
|
256
|
+
|
|
257
|
+
#### Request compression
|
|
258
|
+
|
|
259
|
+
Request compression is not supported by InfluxDB 3 — the client sends uncompressed requests.
|
|
260
|
+
|
|
261
|
+
#### Response compression
|
|
262
|
+
|
|
263
|
+
Response compression is enabled by default. The client sends the `grpc-accept-encoding: identity, deflate, gzip`
|
|
264
|
+
header, and the server returns gzip-compressed responses (if supported). The client automatically
|
|
265
|
+
decompresses them — no configuration required.
|
|
266
|
+
|
|
267
|
+
To **disable response compression**:
|
|
268
|
+
|
|
269
|
+
```python
|
|
270
|
+
# Via constructor parameter
|
|
271
|
+
client = InfluxDBClient3(
|
|
272
|
+
host="your-host",
|
|
273
|
+
token="your-token",
|
|
274
|
+
database="your-database",
|
|
275
|
+
disable_grpc_compression=True
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
# Or via environment variable
|
|
279
|
+
# INFLUX_DISABLE_GRPC_COMPRESSION=true
|
|
280
|
+
client = InfluxDBClient3.from_env()
|
|
281
|
+
```
|
|
282
|
+
|
|
212
283
|
## Windows Users
|
|
213
284
|
Currently, Windows users require an extra installation when querying via Flight natively. This is due to the fact gRPC cannot locate Windows root certificates. To work around this please follow these steps:
|
|
214
285
|
Install `certifi`
|
|
@@ -240,7 +311,10 @@ table = client.query(
|
|
|
240
311
|
|
|
241
312
|
print(table.to_pandas())
|
|
242
313
|
```
|
|
243
|
-
|
|
314
|
+
|
|
315
|
+
You may include your own root certificate in this manner as well.
|
|
316
|
+
|
|
317
|
+
If connecting to InfluxDB fails with error `DNS resolution failed` when using domain name, example `www.mydomain.com`, then try to set environment variable `GRPC_DNS_RESOLVER=native` to see if it works.
|
|
244
318
|
|
|
245
319
|
# Contributing
|
|
246
320
|
|
|
@@ -134,14 +134,46 @@ print(f'DONE writing from csv in {callback.write_count} batch(es)')
|
|
|
134
134
|
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
-
### Pandas
|
|
137
|
+
### Pandas DataFrame
|
|
138
138
|
```python
|
|
139
|
-
|
|
139
|
+
import pandas as pd
|
|
140
|
+
|
|
141
|
+
# Create a DataFrame with a timestamp column
|
|
142
|
+
df = pd.DataFrame({
|
|
143
|
+
'time': pd.to_datetime(['2024-01-01', '2024-01-02', '2024-01-03']),
|
|
144
|
+
'trainer': ['Ash', 'Misty', 'Brock'],
|
|
145
|
+
'pokemon_id': [25, 120, 74],
|
|
146
|
+
'pokemon_name': ['Pikachu', 'Staryu', 'Geodude']
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
# Write the DataFrame - timestamp_column is required for consistency
|
|
150
|
+
client.write_dataframe(
|
|
151
|
+
df,
|
|
152
|
+
measurement='caught',
|
|
153
|
+
timestamp_column='time',
|
|
154
|
+
tags=['trainer', 'pokemon_id']
|
|
155
|
+
)
|
|
140
156
|
```
|
|
141
157
|
|
|
142
|
-
### Polars
|
|
158
|
+
### Polars DataFrame
|
|
143
159
|
```python
|
|
144
|
-
|
|
160
|
+
import polars as pl
|
|
161
|
+
|
|
162
|
+
# Create a DataFrame with a timestamp column
|
|
163
|
+
df = pl.DataFrame({
|
|
164
|
+
'time': ['2024-01-01T00:00:00Z', '2024-01-02T00:00:00Z'],
|
|
165
|
+
'trainer': ['Ash', 'Misty'],
|
|
166
|
+
'pokemon_id': [25, 120],
|
|
167
|
+
'pokemon_name': ['Pikachu', 'Staryu']
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
# Write the DataFrame - same API works for both pandas and polars
|
|
171
|
+
client.write_dataframe(
|
|
172
|
+
df,
|
|
173
|
+
measurement='caught',
|
|
174
|
+
timestamp_column='time',
|
|
175
|
+
tags=['trainer', 'pokemon_id']
|
|
176
|
+
)
|
|
145
177
|
```
|
|
146
178
|
|
|
147
179
|
## Querying
|
|
@@ -154,6 +186,15 @@ table = reader.read_all()
|
|
|
154
186
|
print(table.to_pandas().to_markdown())
|
|
155
187
|
```
|
|
156
188
|
|
|
189
|
+
### Querying to DataFrame
|
|
190
|
+
```python
|
|
191
|
+
# Query directly to a pandas DataFrame (default)
|
|
192
|
+
df = client.query_dataframe("SELECT * FROM caught WHERE trainer = 'Ash'")
|
|
193
|
+
|
|
194
|
+
# Query to a polars DataFrame
|
|
195
|
+
df = client.query_dataframe("SELECT * FROM caught", frame_type="polars")
|
|
196
|
+
```
|
|
197
|
+
|
|
157
198
|
### Querying with influxql
|
|
158
199
|
```python
|
|
159
200
|
query = "select * from measurement"
|
|
@@ -162,6 +203,34 @@ table = reader.read_all()
|
|
|
162
203
|
print(table.to_pandas().to_markdown())
|
|
163
204
|
```
|
|
164
205
|
|
|
206
|
+
### gRPC compression
|
|
207
|
+
|
|
208
|
+
#### Request compression
|
|
209
|
+
|
|
210
|
+
Request compression is not supported by InfluxDB 3 — the client sends uncompressed requests.
|
|
211
|
+
|
|
212
|
+
#### Response compression
|
|
213
|
+
|
|
214
|
+
Response compression is enabled by default. The client sends the `grpc-accept-encoding: identity, deflate, gzip`
|
|
215
|
+
header, and the server returns gzip-compressed responses (if supported). The client automatically
|
|
216
|
+
decompresses them — no configuration required.
|
|
217
|
+
|
|
218
|
+
To **disable response compression**:
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
# Via constructor parameter
|
|
222
|
+
client = InfluxDBClient3(
|
|
223
|
+
host="your-host",
|
|
224
|
+
token="your-token",
|
|
225
|
+
database="your-database",
|
|
226
|
+
disable_grpc_compression=True
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
# Or via environment variable
|
|
230
|
+
# INFLUX_DISABLE_GRPC_COMPRESSION=true
|
|
231
|
+
client = InfluxDBClient3.from_env()
|
|
232
|
+
```
|
|
233
|
+
|
|
165
234
|
## Windows Users
|
|
166
235
|
Currently, Windows users require an extra installation when querying via Flight natively. This is due to the fact gRPC cannot locate Windows root certificates. To work around this please follow these steps:
|
|
167
236
|
Install `certifi`
|
|
@@ -193,7 +262,10 @@ table = client.query(
|
|
|
193
262
|
|
|
194
263
|
print(table.to_pandas())
|
|
195
264
|
```
|
|
196
|
-
|
|
265
|
+
|
|
266
|
+
You may include your own root certificate in this manner as well.
|
|
267
|
+
|
|
268
|
+
If connecting to InfluxDB fails with error `DNS resolution failed` when using domain name, example `www.mydomain.com`, then try to set environment variable `GRPC_DNS_RESOLVER=native` to see if it works.
|
|
197
269
|
|
|
198
270
|
# Contributing
|
|
199
271
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: influxdb3-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.17.0
|
|
4
4
|
Summary: Community Python client for InfluxDB 3.0
|
|
5
5
|
Home-page: https://github.com/InfluxCommunity/influxdb3-python
|
|
6
6
|
Author: InfluxData
|
|
@@ -33,6 +33,8 @@ Provides-Extra: test
|
|
|
33
33
|
Requires-Dist: pytest; extra == "test"
|
|
34
34
|
Requires-Dist: pytest-cov; extra == "test"
|
|
35
35
|
Requires-Dist: pytest-httpserver; extra == "test"
|
|
36
|
+
Requires-Dist: h2<5.0.0,>=4.0.0; extra == "test"
|
|
37
|
+
Requires-Dist: cryptography>=3.4.0; extra == "test"
|
|
36
38
|
Dynamic: author
|
|
37
39
|
Dynamic: author-email
|
|
38
40
|
Dynamic: classifier
|
|
@@ -181,14 +183,46 @@ print(f'DONE writing from csv in {callback.write_count} batch(es)')
|
|
|
181
183
|
|
|
182
184
|
```
|
|
183
185
|
|
|
184
|
-
### Pandas
|
|
186
|
+
### Pandas DataFrame
|
|
185
187
|
```python
|
|
186
|
-
|
|
188
|
+
import pandas as pd
|
|
189
|
+
|
|
190
|
+
# Create a DataFrame with a timestamp column
|
|
191
|
+
df = pd.DataFrame({
|
|
192
|
+
'time': pd.to_datetime(['2024-01-01', '2024-01-02', '2024-01-03']),
|
|
193
|
+
'trainer': ['Ash', 'Misty', 'Brock'],
|
|
194
|
+
'pokemon_id': [25, 120, 74],
|
|
195
|
+
'pokemon_name': ['Pikachu', 'Staryu', 'Geodude']
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
# Write the DataFrame - timestamp_column is required for consistency
|
|
199
|
+
client.write_dataframe(
|
|
200
|
+
df,
|
|
201
|
+
measurement='caught',
|
|
202
|
+
timestamp_column='time',
|
|
203
|
+
tags=['trainer', 'pokemon_id']
|
|
204
|
+
)
|
|
187
205
|
```
|
|
188
206
|
|
|
189
|
-
### Polars
|
|
207
|
+
### Polars DataFrame
|
|
190
208
|
```python
|
|
191
|
-
|
|
209
|
+
import polars as pl
|
|
210
|
+
|
|
211
|
+
# Create a DataFrame with a timestamp column
|
|
212
|
+
df = pl.DataFrame({
|
|
213
|
+
'time': ['2024-01-01T00:00:00Z', '2024-01-02T00:00:00Z'],
|
|
214
|
+
'trainer': ['Ash', 'Misty'],
|
|
215
|
+
'pokemon_id': [25, 120],
|
|
216
|
+
'pokemon_name': ['Pikachu', 'Staryu']
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
# Write the DataFrame - same API works for both pandas and polars
|
|
220
|
+
client.write_dataframe(
|
|
221
|
+
df,
|
|
222
|
+
measurement='caught',
|
|
223
|
+
timestamp_column='time',
|
|
224
|
+
tags=['trainer', 'pokemon_id']
|
|
225
|
+
)
|
|
192
226
|
```
|
|
193
227
|
|
|
194
228
|
## Querying
|
|
@@ -201,6 +235,15 @@ table = reader.read_all()
|
|
|
201
235
|
print(table.to_pandas().to_markdown())
|
|
202
236
|
```
|
|
203
237
|
|
|
238
|
+
### Querying to DataFrame
|
|
239
|
+
```python
|
|
240
|
+
# Query directly to a pandas DataFrame (default)
|
|
241
|
+
df = client.query_dataframe("SELECT * FROM caught WHERE trainer = 'Ash'")
|
|
242
|
+
|
|
243
|
+
# Query to a polars DataFrame
|
|
244
|
+
df = client.query_dataframe("SELECT * FROM caught", frame_type="polars")
|
|
245
|
+
```
|
|
246
|
+
|
|
204
247
|
### Querying with influxql
|
|
205
248
|
```python
|
|
206
249
|
query = "select * from measurement"
|
|
@@ -209,6 +252,34 @@ table = reader.read_all()
|
|
|
209
252
|
print(table.to_pandas().to_markdown())
|
|
210
253
|
```
|
|
211
254
|
|
|
255
|
+
### gRPC compression
|
|
256
|
+
|
|
257
|
+
#### Request compression
|
|
258
|
+
|
|
259
|
+
Request compression is not supported by InfluxDB 3 — the client sends uncompressed requests.
|
|
260
|
+
|
|
261
|
+
#### Response compression
|
|
262
|
+
|
|
263
|
+
Response compression is enabled by default. The client sends the `grpc-accept-encoding: identity, deflate, gzip`
|
|
264
|
+
header, and the server returns gzip-compressed responses (if supported). The client automatically
|
|
265
|
+
decompresses them — no configuration required.
|
|
266
|
+
|
|
267
|
+
To **disable response compression**:
|
|
268
|
+
|
|
269
|
+
```python
|
|
270
|
+
# Via constructor parameter
|
|
271
|
+
client = InfluxDBClient3(
|
|
272
|
+
host="your-host",
|
|
273
|
+
token="your-token",
|
|
274
|
+
database="your-database",
|
|
275
|
+
disable_grpc_compression=True
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
# Or via environment variable
|
|
279
|
+
# INFLUX_DISABLE_GRPC_COMPRESSION=true
|
|
280
|
+
client = InfluxDBClient3.from_env()
|
|
281
|
+
```
|
|
282
|
+
|
|
212
283
|
## Windows Users
|
|
213
284
|
Currently, Windows users require an extra installation when querying via Flight natively. This is due to the fact gRPC cannot locate Windows root certificates. To work around this please follow these steps:
|
|
214
285
|
Install `certifi`
|
|
@@ -240,7 +311,10 @@ table = client.query(
|
|
|
240
311
|
|
|
241
312
|
print(table.to_pandas())
|
|
242
313
|
```
|
|
243
|
-
|
|
314
|
+
|
|
315
|
+
You may include your own root certificate in this manner as well.
|
|
316
|
+
|
|
317
|
+
If connecting to InfluxDB fails with error `DNS resolution failed` when using domain name, example `www.mydomain.com`, then try to set environment variable `GRPC_DNS_RESOLVER=native` to see if it works.
|
|
244
318
|
|
|
245
319
|
# Contributing
|
|
246
320
|
|
|
@@ -14,6 +14,7 @@ Examples/handle_query_error.py
|
|
|
14
14
|
Examples/pandas_write.py
|
|
15
15
|
Examples/query_async.py
|
|
16
16
|
Examples/query_type.py
|
|
17
|
+
Examples/timeouts.py
|
|
17
18
|
influxdb3_python.egg-info/PKG-INFO
|
|
18
19
|
influxdb3_python.egg-info/SOURCES.txt
|
|
19
20
|
influxdb3_python.egg-info/dependency_links.txt
|
|
@@ -62,6 +63,7 @@ tests/test_api_client.py
|
|
|
62
63
|
tests/test_dataframe_serializer.py
|
|
63
64
|
tests/test_date_helper.py
|
|
64
65
|
tests/test_deep_merge.py
|
|
66
|
+
tests/test_flush.py
|
|
65
67
|
tests/test_influxdb_client_3.py
|
|
66
68
|
tests/test_influxdb_client_3_integration.py
|
|
67
69
|
tests/test_merge_options.py
|