influxdb3-python 0.13.0__tar.gz → 0.14.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.14.0/Examples/handle_query_error.py +33 -0
- {influxdb3_python-0.13.0/influxdb3_python.egg-info → influxdb3_python-0.14.0}/PKG-INFO +26 -4
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/README.md +24 -2
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0/influxdb3_python.egg-info}/PKG-INFO +26 -4
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb3_python.egg-info/SOURCES.txt +8 -2
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb3_python.egg-info/requires.txt +1 -1
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/__init__.py +39 -8
- influxdb3_python-0.14.0/influxdb_client_3/exceptions/__init__.py +3 -0
- {influxdb3_python-0.13.0/influxdb_client_3/write_client/client → influxdb3_python-0.14.0/influxdb_client_3/exceptions}/exceptions.py +35 -2
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/query/query_api.py +10 -16
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/version.py +1 -1
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/client/_base.py +2 -2
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/client/util/multiprocessing_helper.py +1 -1
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/client/write/retry.py +1 -1
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/client/write_api.py +18 -6
- influxdb3_python-0.14.0/influxdb_client_3/write_client/domain/write_precision_converter.py +30 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/rest.py +1 -1
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/service/signin_service.py +1 -1
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/service/signout_service.py +1 -1
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/service/write_service.py +52 -26
- influxdb3_python-0.14.0/pyproject.toml +3 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/setup.py +1 -2
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/tests/test_api_client.py +1 -1
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/tests/test_influxdb_client_3.py +88 -4
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/tests/test_influxdb_client_3_integration.py +3 -3
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/tests/test_polars.py +1 -0
- influxdb3_python-0.14.0/tests/test_write_local_server.py +129 -0
- influxdb3_python-0.14.0/tests/test_write_precision_converter.py +37 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/Examples/__init__.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/Examples/basic_ssl_example.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/Examples/batching_example.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/Examples/cloud_dedicated_query.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/Examples/cloud_dedicated_write.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/Examples/config.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/Examples/flight_options_example.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/Examples/handle_http_error.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/Examples/pandas_write.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/Examples/query_async.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/Examples/query_type.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/LICENSE +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb3_python.egg-info/dependency_links.txt +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb3_python.egg-info/top_level.txt +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/py.typed +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/query/__init__.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/read_file.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/__init__.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/_sync/__init__.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/_sync/api_client.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/_sync/rest.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/client/__init__.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/client/influxdb_client.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/client/logging_handler.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/client/util/__init__.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/client/util/date_utils.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/client/util/date_utils_pandas.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/client/util/helpers.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/client/warnings.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/client/write/__init__.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/client/write/dataframe_serializer.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/client/write/point.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/client/write/polars_dataframe_serializer.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/configuration.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/domain/__init__.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/domain/write_precision.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/extras.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/service/__init__.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/service/_base_service.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/setup.cfg +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/tests/test_dataframe_serializer.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/tests/test_date_helper.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/tests/test_deep_merge.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/tests/test_merge_options.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/tests/test_point.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/tests/test_query.py +0 -0
- {influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/tests/test_write_file.py +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Demonstrates handling error when querying InfluxDB.
|
|
3
|
+
"""
|
|
4
|
+
import logging
|
|
5
|
+
from config import Config
|
|
6
|
+
from influxdb_client_3.exceptions import InfluxDB3ClientQueryError
|
|
7
|
+
|
|
8
|
+
import influxdb_client_3 as InfluxDBClient3
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def main() -> None:
|
|
12
|
+
"""
|
|
13
|
+
Main function
|
|
14
|
+
:return:
|
|
15
|
+
"""
|
|
16
|
+
config = Config()
|
|
17
|
+
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO)
|
|
18
|
+
|
|
19
|
+
client = InfluxDBClient3.InfluxDBClient3(
|
|
20
|
+
host=config.host,
|
|
21
|
+
token=config.token,
|
|
22
|
+
database=config.database
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
try:
|
|
26
|
+
# Select from a bucket that doesn't exist
|
|
27
|
+
client.query("Select a from cpu11")
|
|
28
|
+
except InfluxDB3ClientQueryError as e:
|
|
29
|
+
logging.log(logging.ERROR, e.message)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
if __name__ == "__main__":
|
|
33
|
+
main()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: influxdb3-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.14.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
|
|
@@ -20,7 +20,6 @@ License-File: LICENSE
|
|
|
20
20
|
Requires-Dist: reactivex>=4.0.4
|
|
21
21
|
Requires-Dist: certifi>=14.05.14
|
|
22
22
|
Requires-Dist: python_dateutil>=2.5.3
|
|
23
|
-
Requires-Dist: setuptools>=21.0.0
|
|
24
23
|
Requires-Dist: urllib3>=1.26.0
|
|
25
24
|
Requires-Dist: pyarrow>=8.0.0
|
|
26
25
|
Provides-Extra: pandas
|
|
@@ -33,6 +32,7 @@ Requires-Dist: polars; extra == "dataframe"
|
|
|
33
32
|
Provides-Extra: test
|
|
34
33
|
Requires-Dist: pytest; extra == "test"
|
|
35
34
|
Requires-Dist: pytest-cov; extra == "test"
|
|
35
|
+
Requires-Dist: pytest-httpserver; extra == "test"
|
|
36
36
|
Dynamic: author
|
|
37
37
|
Dynamic: author-email
|
|
38
38
|
Dynamic: classifier
|
|
@@ -45,6 +45,7 @@ Dynamic: requires-dist
|
|
|
45
45
|
Dynamic: requires-python
|
|
46
46
|
Dynamic: summary
|
|
47
47
|
|
|
48
|
+
<!--home-start-->
|
|
48
49
|
<p align="center">
|
|
49
50
|
<img src="https://github.com/InfluxCommunity/influxdb3-python/blob/main/python-logo.png?raw=true" alt="Your Image" width="150px">
|
|
50
51
|
</p>
|
|
@@ -95,7 +96,7 @@ Note: This does not include Pandas support. If you would like to use key feature
|
|
|
95
96
|
*Note: Please make sure you are using 3.6 or above. For the best performance use 3.11+*
|
|
96
97
|
|
|
97
98
|
# Usage
|
|
98
|
-
One of the easiest ways to get started is to checkout the ["Pokemon Trainer Cookbook"](Examples/pokemon-trainer/cookbook.ipynb). This scenario takes you through the basics of both the client library and Pyarrow.
|
|
99
|
+
One of the easiest ways to get started is to checkout the ["Pokemon Trainer Cookbook"](https://github.com/InfluxCommunity/influxdb3-python/blob/main/Examples/pokemon-trainer/cookbook.ipynb). This scenario takes you through the basics of both the client library and Pyarrow.
|
|
99
100
|
|
|
100
101
|
## Importing the Module
|
|
101
102
|
```python
|
|
@@ -104,7 +105,7 @@ from influxdb_client_3 import InfluxDBClient3, Point
|
|
|
104
105
|
|
|
105
106
|
## Initialization
|
|
106
107
|
If you are using InfluxDB Cloud, then you should note that:
|
|
107
|
-
1. Use bucket name for
|
|
108
|
+
1. Use bucket name for `database` or `bucket` in function argument.
|
|
108
109
|
|
|
109
110
|
```python
|
|
110
111
|
client = InfluxDBClient3(token="your-token",
|
|
@@ -240,3 +241,24 @@ table = client.query(
|
|
|
240
241
|
print(table.to_pandas())
|
|
241
242
|
```
|
|
242
243
|
You may also include your own root certificate via this manor aswell.
|
|
244
|
+
|
|
245
|
+
# Contributing
|
|
246
|
+
|
|
247
|
+
Tests are run using `pytest`.
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
# Clone the repository
|
|
251
|
+
git clone https://github.com/InfluxCommunity/influxdb3-python
|
|
252
|
+
cd influxdb3-python
|
|
253
|
+
|
|
254
|
+
# Create a virtual environment and activate it
|
|
255
|
+
python3 -m venv .venv
|
|
256
|
+
source .venv/bin/activate
|
|
257
|
+
|
|
258
|
+
# Install the package and its dependencies
|
|
259
|
+
pip install -e .[pandas,polars,dataframe,test]
|
|
260
|
+
|
|
261
|
+
# Run the tests
|
|
262
|
+
python -m pytest .
|
|
263
|
+
```
|
|
264
|
+
<!--home-end-->
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!--home-start-->
|
|
1
2
|
<p align="center">
|
|
2
3
|
<img src="https://github.com/InfluxCommunity/influxdb3-python/blob/main/python-logo.png?raw=true" alt="Your Image" width="150px">
|
|
3
4
|
</p>
|
|
@@ -48,7 +49,7 @@ Note: This does not include Pandas support. If you would like to use key feature
|
|
|
48
49
|
*Note: Please make sure you are using 3.6 or above. For the best performance use 3.11+*
|
|
49
50
|
|
|
50
51
|
# Usage
|
|
51
|
-
One of the easiest ways to get started is to checkout the ["Pokemon Trainer Cookbook"](Examples/pokemon-trainer/cookbook.ipynb). This scenario takes you through the basics of both the client library and Pyarrow.
|
|
52
|
+
One of the easiest ways to get started is to checkout the ["Pokemon Trainer Cookbook"](https://github.com/InfluxCommunity/influxdb3-python/blob/main/Examples/pokemon-trainer/cookbook.ipynb). This scenario takes you through the basics of both the client library and Pyarrow.
|
|
52
53
|
|
|
53
54
|
## Importing the Module
|
|
54
55
|
```python
|
|
@@ -57,7 +58,7 @@ from influxdb_client_3 import InfluxDBClient3, Point
|
|
|
57
58
|
|
|
58
59
|
## Initialization
|
|
59
60
|
If you are using InfluxDB Cloud, then you should note that:
|
|
60
|
-
1. Use bucket name for
|
|
61
|
+
1. Use bucket name for `database` or `bucket` in function argument.
|
|
61
62
|
|
|
62
63
|
```python
|
|
63
64
|
client = InfluxDBClient3(token="your-token",
|
|
@@ -193,3 +194,24 @@ table = client.query(
|
|
|
193
194
|
print(table.to_pandas())
|
|
194
195
|
```
|
|
195
196
|
You may also include your own root certificate via this manor aswell.
|
|
197
|
+
|
|
198
|
+
# Contributing
|
|
199
|
+
|
|
200
|
+
Tests are run using `pytest`.
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# Clone the repository
|
|
204
|
+
git clone https://github.com/InfluxCommunity/influxdb3-python
|
|
205
|
+
cd influxdb3-python
|
|
206
|
+
|
|
207
|
+
# Create a virtual environment and activate it
|
|
208
|
+
python3 -m venv .venv
|
|
209
|
+
source .venv/bin/activate
|
|
210
|
+
|
|
211
|
+
# Install the package and its dependencies
|
|
212
|
+
pip install -e .[pandas,polars,dataframe,test]
|
|
213
|
+
|
|
214
|
+
# Run the tests
|
|
215
|
+
python -m pytest .
|
|
216
|
+
```
|
|
217
|
+
<!--home-end-->
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: influxdb3-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.14.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
|
|
@@ -20,7 +20,6 @@ License-File: LICENSE
|
|
|
20
20
|
Requires-Dist: reactivex>=4.0.4
|
|
21
21
|
Requires-Dist: certifi>=14.05.14
|
|
22
22
|
Requires-Dist: python_dateutil>=2.5.3
|
|
23
|
-
Requires-Dist: setuptools>=21.0.0
|
|
24
23
|
Requires-Dist: urllib3>=1.26.0
|
|
25
24
|
Requires-Dist: pyarrow>=8.0.0
|
|
26
25
|
Provides-Extra: pandas
|
|
@@ -33,6 +32,7 @@ Requires-Dist: polars; extra == "dataframe"
|
|
|
33
32
|
Provides-Extra: test
|
|
34
33
|
Requires-Dist: pytest; extra == "test"
|
|
35
34
|
Requires-Dist: pytest-cov; extra == "test"
|
|
35
|
+
Requires-Dist: pytest-httpserver; extra == "test"
|
|
36
36
|
Dynamic: author
|
|
37
37
|
Dynamic: author-email
|
|
38
38
|
Dynamic: classifier
|
|
@@ -45,6 +45,7 @@ Dynamic: requires-dist
|
|
|
45
45
|
Dynamic: requires-python
|
|
46
46
|
Dynamic: summary
|
|
47
47
|
|
|
48
|
+
<!--home-start-->
|
|
48
49
|
<p align="center">
|
|
49
50
|
<img src="https://github.com/InfluxCommunity/influxdb3-python/blob/main/python-logo.png?raw=true" alt="Your Image" width="150px">
|
|
50
51
|
</p>
|
|
@@ -95,7 +96,7 @@ Note: This does not include Pandas support. If you would like to use key feature
|
|
|
95
96
|
*Note: Please make sure you are using 3.6 or above. For the best performance use 3.11+*
|
|
96
97
|
|
|
97
98
|
# Usage
|
|
98
|
-
One of the easiest ways to get started is to checkout the ["Pokemon Trainer Cookbook"](Examples/pokemon-trainer/cookbook.ipynb). This scenario takes you through the basics of both the client library and Pyarrow.
|
|
99
|
+
One of the easiest ways to get started is to checkout the ["Pokemon Trainer Cookbook"](https://github.com/InfluxCommunity/influxdb3-python/blob/main/Examples/pokemon-trainer/cookbook.ipynb). This scenario takes you through the basics of both the client library and Pyarrow.
|
|
99
100
|
|
|
100
101
|
## Importing the Module
|
|
101
102
|
```python
|
|
@@ -104,7 +105,7 @@ from influxdb_client_3 import InfluxDBClient3, Point
|
|
|
104
105
|
|
|
105
106
|
## Initialization
|
|
106
107
|
If you are using InfluxDB Cloud, then you should note that:
|
|
107
|
-
1. Use bucket name for
|
|
108
|
+
1. Use bucket name for `database` or `bucket` in function argument.
|
|
108
109
|
|
|
109
110
|
```python
|
|
110
111
|
client = InfluxDBClient3(token="your-token",
|
|
@@ -240,3 +241,24 @@ table = client.query(
|
|
|
240
241
|
print(table.to_pandas())
|
|
241
242
|
```
|
|
242
243
|
You may also include your own root certificate via this manor aswell.
|
|
244
|
+
|
|
245
|
+
# Contributing
|
|
246
|
+
|
|
247
|
+
Tests are run using `pytest`.
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
# Clone the repository
|
|
251
|
+
git clone https://github.com/InfluxCommunity/influxdb3-python
|
|
252
|
+
cd influxdb3-python
|
|
253
|
+
|
|
254
|
+
# Create a virtual environment and activate it
|
|
255
|
+
python3 -m venv .venv
|
|
256
|
+
source .venv/bin/activate
|
|
257
|
+
|
|
258
|
+
# Install the package and its dependencies
|
|
259
|
+
pip install -e .[pandas,polars,dataframe,test]
|
|
260
|
+
|
|
261
|
+
# Run the tests
|
|
262
|
+
python -m pytest .
|
|
263
|
+
```
|
|
264
|
+
<!--home-end-->
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
LICENSE
|
|
2
2
|
README.md
|
|
3
|
+
pyproject.toml
|
|
3
4
|
setup.py
|
|
4
5
|
Examples/__init__.py
|
|
5
6
|
Examples/basic_ssl_example.py
|
|
@@ -9,6 +10,7 @@ Examples/cloud_dedicated_write.py
|
|
|
9
10
|
Examples/config.py
|
|
10
11
|
Examples/flight_options_example.py
|
|
11
12
|
Examples/handle_http_error.py
|
|
13
|
+
Examples/handle_query_error.py
|
|
12
14
|
Examples/pandas_write.py
|
|
13
15
|
Examples/query_async.py
|
|
14
16
|
Examples/query_type.py
|
|
@@ -21,6 +23,8 @@ influxdb_client_3/__init__.py
|
|
|
21
23
|
influxdb_client_3/py.typed
|
|
22
24
|
influxdb_client_3/read_file.py
|
|
23
25
|
influxdb_client_3/version.py
|
|
26
|
+
influxdb_client_3/exceptions/__init__.py
|
|
27
|
+
influxdb_client_3/exceptions/exceptions.py
|
|
24
28
|
influxdb_client_3/query/__init__.py
|
|
25
29
|
influxdb_client_3/query/query_api.py
|
|
26
30
|
influxdb_client_3/write_client/__init__.py
|
|
@@ -32,7 +36,6 @@ influxdb_client_3/write_client/_sync/api_client.py
|
|
|
32
36
|
influxdb_client_3/write_client/_sync/rest.py
|
|
33
37
|
influxdb_client_3/write_client/client/__init__.py
|
|
34
38
|
influxdb_client_3/write_client/client/_base.py
|
|
35
|
-
influxdb_client_3/write_client/client/exceptions.py
|
|
36
39
|
influxdb_client_3/write_client/client/influxdb_client.py
|
|
37
40
|
influxdb_client_3/write_client/client/logging_handler.py
|
|
38
41
|
influxdb_client_3/write_client/client/warnings.py
|
|
@@ -49,6 +52,7 @@ influxdb_client_3/write_client/client/write/polars_dataframe_serializer.py
|
|
|
49
52
|
influxdb_client_3/write_client/client/write/retry.py
|
|
50
53
|
influxdb_client_3/write_client/domain/__init__.py
|
|
51
54
|
influxdb_client_3/write_client/domain/write_precision.py
|
|
55
|
+
influxdb_client_3/write_client/domain/write_precision_converter.py
|
|
52
56
|
influxdb_client_3/write_client/service/__init__.py
|
|
53
57
|
influxdb_client_3/write_client/service/_base_service.py
|
|
54
58
|
influxdb_client_3/write_client/service/signin_service.py
|
|
@@ -64,4 +68,6 @@ tests/test_merge_options.py
|
|
|
64
68
|
tests/test_point.py
|
|
65
69
|
tests/test_polars.py
|
|
66
70
|
tests/test_query.py
|
|
67
|
-
tests/test_write_file.py
|
|
71
|
+
tests/test_write_file.py
|
|
72
|
+
tests/test_write_local_server.py
|
|
73
|
+
tests/test_write_precision_converter.py
|
|
@@ -4,11 +4,13 @@ import urllib.parse
|
|
|
4
4
|
from typing import Any
|
|
5
5
|
|
|
6
6
|
import pyarrow as pa
|
|
7
|
+
from pyarrow import ArrowException
|
|
7
8
|
|
|
9
|
+
from influxdb_client_3.exceptions import InfluxDB3ClientQueryError
|
|
10
|
+
from influxdb_client_3.exceptions import InfluxDBError
|
|
8
11
|
from influxdb_client_3.query.query_api import QueryApi as _QueryApi, QueryApiOptionsBuilder
|
|
9
12
|
from influxdb_client_3.read_file import UploadFile
|
|
10
13
|
from influxdb_client_3.write_client import InfluxDBClient as _InfluxDBClient, WriteOptions, Point
|
|
11
|
-
from influxdb_client_3.write_client.client.exceptions import InfluxDBError
|
|
12
14
|
from influxdb_client_3.write_client.client.write_api import WriteApi as _WriteApi, SYNCHRONOUS, ASYNCHRONOUS, \
|
|
13
15
|
PointSettings, DefaultWriteOptions, WriteType
|
|
14
16
|
from influxdb_client_3.write_client.domain.write_precision import WritePrecision
|
|
@@ -22,6 +24,7 @@ INFLUX_ORG = "INFLUX_ORG"
|
|
|
22
24
|
INFLUX_PRECISION = "INFLUX_PRECISION"
|
|
23
25
|
INFLUX_AUTH_SCHEME = "INFLUX_AUTH_SCHEME"
|
|
24
26
|
INFLUX_GZIP_THRESHOLD = "INFLUX_GZIP_THRESHOLD"
|
|
27
|
+
INFLUX_WRITE_NO_SYNC = "INFLUX_WRITE_NO_SYNC"
|
|
25
28
|
|
|
26
29
|
|
|
27
30
|
def write_client_options(**kwargs):
|
|
@@ -110,9 +113,15 @@ def _parse_precision(precision):
|
|
|
110
113
|
:rtype: WritePrecision
|
|
111
114
|
:raises ValueError: If the provided precision is not valid.
|
|
112
115
|
"""
|
|
113
|
-
if precision
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
if precision == WritePrecision.NS or precision == "nanosecond":
|
|
117
|
+
return WritePrecision.NS
|
|
118
|
+
if precision == WritePrecision.US or precision == "microsecond":
|
|
119
|
+
return WritePrecision.US
|
|
120
|
+
if precision == WritePrecision.MS or precision == "millisecond":
|
|
121
|
+
return WritePrecision.MS
|
|
122
|
+
if precision == WritePrecision.S or precision == "second":
|
|
123
|
+
return WritePrecision.S
|
|
124
|
+
raise ValueError(f"Invalid precision value: {precision}")
|
|
116
125
|
|
|
117
126
|
|
|
118
127
|
def _parse_gzip_threshold(threshold):
|
|
@@ -139,6 +148,21 @@ def _parse_gzip_threshold(threshold):
|
|
|
139
148
|
return threshold
|
|
140
149
|
|
|
141
150
|
|
|
151
|
+
def _parse_write_no_sync(write_no_sync):
|
|
152
|
+
"""
|
|
153
|
+
Parses and validates the provided write no sync value.
|
|
154
|
+
|
|
155
|
+
This function ensures that the given value is a valid boolean,
|
|
156
|
+
and it raises an appropriate error if the value is not valid.
|
|
157
|
+
|
|
158
|
+
:param write_no_sync: The input value to be parsed and validated.
|
|
159
|
+
:type write_no_sync: Any
|
|
160
|
+
:return: The validated write no sync value as an boolean.
|
|
161
|
+
:rtype: bool
|
|
162
|
+
"""
|
|
163
|
+
return write_no_sync.strip().lower() in ['true', '1', 't', 'y', 'yes']
|
|
164
|
+
|
|
165
|
+
|
|
142
166
|
class InfluxDBClient3:
|
|
143
167
|
def __init__(
|
|
144
168
|
self,
|
|
@@ -195,14 +219,17 @@ class InfluxDBClient3:
|
|
|
195
219
|
|
|
196
220
|
write_type = DefaultWriteOptions.write_type.value
|
|
197
221
|
write_precision = DefaultWriteOptions.write_precision.value
|
|
222
|
+
write_no_sync = DefaultWriteOptions.no_sync.value
|
|
198
223
|
if isinstance(write_client_options, dict) and write_client_options.get('write_options') is not None:
|
|
199
224
|
write_opts = write_client_options['write_options']
|
|
200
225
|
write_type = getattr(write_opts, 'write_type', write_type)
|
|
201
226
|
write_precision = getattr(write_opts, 'write_precision', write_precision)
|
|
227
|
+
write_no_sync = getattr(write_opts, 'no_sync', write_no_sync)
|
|
202
228
|
|
|
203
229
|
write_options = WriteOptions(
|
|
204
230
|
write_type=write_type,
|
|
205
231
|
write_precision=write_precision,
|
|
232
|
+
no_sync=write_no_sync,
|
|
206
233
|
)
|
|
207
234
|
|
|
208
235
|
self._write_client_options = {
|
|
@@ -284,6 +311,10 @@ class InfluxDBClient3:
|
|
|
284
311
|
kwargs['gzip_threshold'] = _parse_gzip_threshold(gzip_threshold)
|
|
285
312
|
kwargs['enable_gzip'] = True
|
|
286
313
|
|
|
314
|
+
write_no_sync = os.getenv(INFLUX_WRITE_NO_SYNC)
|
|
315
|
+
if write_no_sync is not None:
|
|
316
|
+
write_options.no_sync = _parse_write_no_sync(write_no_sync)
|
|
317
|
+
|
|
287
318
|
precision = os.getenv(INFLUX_PRECISION)
|
|
288
319
|
if precision is not None:
|
|
289
320
|
write_options.write_precision = _parse_precision(precision)
|
|
@@ -400,8 +431,8 @@ class InfluxDBClient3:
|
|
|
400
431
|
|
|
401
432
|
try:
|
|
402
433
|
return self._query_api.query(query=query, language=language, mode=mode, database=database, **kwargs)
|
|
403
|
-
except
|
|
404
|
-
raise e
|
|
434
|
+
except ArrowException as e:
|
|
435
|
+
raise InfluxDB3ClientQueryError(f"Error while executing query: {e}")
|
|
405
436
|
|
|
406
437
|
async def query_async(self, query: str, language: str = "sql", mode: str = "all", database: str = None, **kwargs):
|
|
407
438
|
"""Query data from InfluxDB asynchronously.
|
|
@@ -433,8 +464,8 @@ class InfluxDBClient3:
|
|
|
433
464
|
mode=mode,
|
|
434
465
|
database=database,
|
|
435
466
|
**kwargs)
|
|
436
|
-
except
|
|
437
|
-
raise e
|
|
467
|
+
except ArrowException as e:
|
|
468
|
+
raise InfluxDB3ClientQueryError(f"Error while executing query: {e}")
|
|
438
469
|
|
|
439
470
|
def close(self):
|
|
440
471
|
"""Close the client and clean up resources."""
|
|
@@ -4,10 +4,43 @@ import logging
|
|
|
4
4
|
|
|
5
5
|
from urllib3 import HTTPResponse
|
|
6
6
|
|
|
7
|
-
logger = logging.getLogger('influxdb_client_3.
|
|
7
|
+
logger = logging.getLogger('influxdb_client_3.exceptions')
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
class
|
|
10
|
+
class InfluxDB3ClientError(Exception):
|
|
11
|
+
"""
|
|
12
|
+
Exception raised for errors in the InfluxDB client operations.
|
|
13
|
+
|
|
14
|
+
Represents errors that occur during interactions with the InfluxDB
|
|
15
|
+
database client. This exception is a general base class for more
|
|
16
|
+
specific client-related failures and is typically used to signal issues
|
|
17
|
+
such as invalid queries, connection failures, or API misusage.
|
|
18
|
+
"""
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# This error is for all query operations
|
|
23
|
+
class InfluxDB3ClientQueryError(InfluxDB3ClientError):
|
|
24
|
+
"""
|
|
25
|
+
Represents an error that occurs when querying an InfluxDB client.
|
|
26
|
+
|
|
27
|
+
This class is specifically designed to handle errors originating from
|
|
28
|
+
client queries to an InfluxDB database. It extends the general
|
|
29
|
+
`InfluxDBClientError`, allowing more precise identification and
|
|
30
|
+
handling of query-related issues.
|
|
31
|
+
|
|
32
|
+
:ivar message: Contains the specific error message describing the
|
|
33
|
+
query error.
|
|
34
|
+
:type message: str
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
def __init__(self, error_message, *args, **kwargs):
|
|
38
|
+
super().__init__(error_message, *args, **kwargs)
|
|
39
|
+
self.message = error_message
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# This error is for all write operations
|
|
43
|
+
class InfluxDBError(InfluxDB3ClientError):
|
|
11
44
|
"""Raised when a server error occurs."""
|
|
12
45
|
|
|
13
46
|
def __init__(self, response: HTTPResponse = None, message: str = None):
|
|
@@ -162,14 +162,11 @@ class QueryApi(object):
|
|
|
162
162
|
It should be a ``dictionary`` of key-value pairs.
|
|
163
163
|
:return: The query result in the specified mode.
|
|
164
164
|
"""
|
|
165
|
-
|
|
166
|
-
ticket, _options = self._prepare_query(query, language, database, **kwargs)
|
|
165
|
+
ticket, _options = self._prepare_query(query, language, database, **kwargs)
|
|
167
166
|
|
|
168
|
-
|
|
167
|
+
flight_reader = self._do_get(ticket, _options)
|
|
169
168
|
|
|
170
|
-
|
|
171
|
-
except Exception as e:
|
|
172
|
-
raise e
|
|
169
|
+
return self._translate_stream_reader(flight_reader, mode)
|
|
173
170
|
|
|
174
171
|
async def query_async(self, query: str, language: str, mode: str, database: str, **kwargs):
|
|
175
172
|
"""Query data from InfluxDB asynchronously.
|
|
@@ -187,16 +184,13 @@ class QueryApi(object):
|
|
|
187
184
|
It should be a ``dictionary`` of key-value pairs.
|
|
188
185
|
:return: The query result in the specified mode.
|
|
189
186
|
"""
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
mode)
|
|
198
|
-
except Exception as e:
|
|
199
|
-
raise e
|
|
187
|
+
ticket, options = self._prepare_query(query, language, database, **kwargs)
|
|
188
|
+
loop = asyncio.get_running_loop()
|
|
189
|
+
_flight_reader = await loop.run_in_executor(None,
|
|
190
|
+
self._flight_client.do_get, ticket, options)
|
|
191
|
+
return await loop.run_in_executor(None, self._translate_stream_reader,
|
|
192
|
+
_flight_reader,
|
|
193
|
+
mode)
|
|
200
194
|
|
|
201
195
|
def _translate_stream_reader(self, reader: FlightStreamReader, mode: str):
|
|
202
196
|
from influxdb_client_3 import polars as has_polars
|
{influxdb3_python-0.13.0 → influxdb3_python-0.14.0}/influxdb_client_3/write_client/client/_base.py
RENAMED
|
@@ -282,7 +282,7 @@ class _Configuration(Configuration):
|
|
|
282
282
|
super().update_request_header_params(path, params, should_gzip)
|
|
283
283
|
if should_gzip:
|
|
284
284
|
# GZIP Request
|
|
285
|
-
if path == '/api/v2/write':
|
|
285
|
+
if path == '/api/v2/write' or path == '/api/v3/write_lp':
|
|
286
286
|
params["Content-Encoding"] = "gzip"
|
|
287
287
|
params["Accept-Encoding"] = "identity"
|
|
288
288
|
pass
|
|
@@ -298,7 +298,7 @@ class _Configuration(Configuration):
|
|
|
298
298
|
_body = super().update_request_body(path, body, should_gzip)
|
|
299
299
|
if should_gzip:
|
|
300
300
|
# GZIP Request
|
|
301
|
-
if path == '/api/v2/write':
|
|
301
|
+
if path == '/api/v2/write' or path == '/api/v3/write_lp':
|
|
302
302
|
import gzip
|
|
303
303
|
if isinstance(_body, bytes):
|
|
304
304
|
return gzip.compress(data=_body)
|
|
@@ -8,7 +8,7 @@ import logging
|
|
|
8
8
|
import multiprocessing
|
|
9
9
|
|
|
10
10
|
from influxdb_client_3.write_client import InfluxDBClient, WriteOptions
|
|
11
|
-
from influxdb_client_3.
|
|
11
|
+
from influxdb_client_3.exceptions import InfluxDBError
|
|
12
12
|
|
|
13
13
|
logger = logging.getLogger('influxdb_client.client.util.multiprocessing_helper')
|
|
14
14
|
|
|
@@ -9,7 +9,7 @@ from typing import Callable
|
|
|
9
9
|
from urllib3 import Retry
|
|
10
10
|
from urllib3.exceptions import MaxRetryError, ResponseError
|
|
11
11
|
|
|
12
|
-
from influxdb_client_3.
|
|
12
|
+
from influxdb_client_3.exceptions import InfluxDBError
|
|
13
13
|
|
|
14
14
|
logger = logging.getLogger('influxdb_client.client.write.retry')
|
|
15
15
|
|
|
@@ -24,6 +24,8 @@ from influxdb_client_3.write_client.client.write.retry import WritesRetry
|
|
|
24
24
|
from influxdb_client_3.write_client.domain import WritePrecision
|
|
25
25
|
from influxdb_client_3.write_client.rest import _UTF_8_encoding
|
|
26
26
|
|
|
27
|
+
DEFAULT_WRITE_NO_SYNC = False
|
|
28
|
+
|
|
27
29
|
logger = logging.getLogger('influxdb_client_3.write_client.client.write_api')
|
|
28
30
|
|
|
29
31
|
if _HAS_DATACLASS:
|
|
@@ -41,7 +43,8 @@ class WriteType(Enum):
|
|
|
41
43
|
|
|
42
44
|
class DefaultWriteOptions(Enum):
|
|
43
45
|
write_type = WriteType.synchronous
|
|
44
|
-
write_precision =
|
|
46
|
+
write_precision = DEFAULT_WRITE_PRECISION
|
|
47
|
+
no_sync = DEFAULT_WRITE_NO_SYNC
|
|
45
48
|
|
|
46
49
|
|
|
47
50
|
class WriteOptions(object):
|
|
@@ -57,6 +60,7 @@ class WriteOptions(object):
|
|
|
57
60
|
exponential_base=2,
|
|
58
61
|
max_close_wait=300_000,
|
|
59
62
|
write_precision=DEFAULT_WRITE_PRECISION,
|
|
63
|
+
no_sync=DEFAULT_WRITE_NO_SYNC,
|
|
60
64
|
write_scheduler=ThreadPoolScheduler(max_workers=1)) -> None:
|
|
61
65
|
"""
|
|
62
66
|
Create write api configuration.
|
|
@@ -72,7 +76,9 @@ class WriteOptions(object):
|
|
|
72
76
|
:param max_retry_delay: the maximum delay between each retry attempt in milliseconds
|
|
73
77
|
:param max_retry_time: total timeout for all retry attempts in milliseconds, if 0 retry is disabled
|
|
74
78
|
:param exponential_base: base for the exponential retry delay
|
|
75
|
-
:
|
|
79
|
+
:param max_close_wait: the maximum time to wait for writes to be flushed if close() is called
|
|
80
|
+
:param write_precision: precision to use when writing points to InfluxDB
|
|
81
|
+
:param no_sync: skip waiting for WAL persistence on write
|
|
76
82
|
:param write_scheduler:
|
|
77
83
|
"""
|
|
78
84
|
self.write_type = write_type
|
|
@@ -87,6 +93,7 @@ class WriteOptions(object):
|
|
|
87
93
|
self.write_scheduler = write_scheduler
|
|
88
94
|
self.max_close_wait = max_close_wait
|
|
89
95
|
self.write_precision = write_precision
|
|
96
|
+
self.no_sync = no_sync
|
|
90
97
|
|
|
91
98
|
def to_retry_strategy(self, **kwargs):
|
|
92
99
|
"""
|
|
@@ -202,7 +209,7 @@ def _body_reduce(batch_items):
|
|
|
202
209
|
|
|
203
210
|
class WriteApi(_BaseWriteApi):
|
|
204
211
|
"""
|
|
205
|
-
Implementation for '/api/v2/write' endpoint.
|
|
212
|
+
Implementation for '/api/v2/write' and '/api/v3/write_lp' endpoint.
|
|
206
213
|
|
|
207
214
|
Example:
|
|
208
215
|
.. code-block:: python
|
|
@@ -375,6 +382,8 @@ You can use native asynchronous version of the client:
|
|
|
375
382
|
return self._write_batching(bucket, org, record,
|
|
376
383
|
write_precision, **kwargs)
|
|
377
384
|
|
|
385
|
+
no_sync = self._write_options.no_sync
|
|
386
|
+
|
|
378
387
|
payloads = defaultdict(list)
|
|
379
388
|
self._serialize(record, write_precision, payloads, **kwargs)
|
|
380
389
|
|
|
@@ -382,7 +391,7 @@ You can use native asynchronous version of the client:
|
|
|
382
391
|
|
|
383
392
|
def write_payload(payload):
|
|
384
393
|
final_string = b'\n'.join(payload[1])
|
|
385
|
-
return self._post_write(_async_req, bucket, org, final_string, payload[0])
|
|
394
|
+
return self._post_write(_async_req, bucket, org, final_string, payload[0], no_sync)
|
|
386
395
|
|
|
387
396
|
results = list(map(write_payload, payloads.items()))
|
|
388
397
|
if not _async_req:
|
|
@@ -519,18 +528,21 @@ You can use native asynchronous version of the client:
|
|
|
519
528
|
else:
|
|
520
529
|
_retry_callback_delegate = None
|
|
521
530
|
|
|
531
|
+
no_sync = self._write_options.no_sync
|
|
532
|
+
|
|
522
533
|
retry = self._write_options.to_retry_strategy(retry_callback=_retry_callback_delegate)
|
|
523
534
|
|
|
524
535
|
self._post_write(False, batch_item.key.bucket, batch_item.key.org, batch_item.data,
|
|
525
|
-
batch_item.key.precision, urlopen_kw={'retries': retry})
|
|
536
|
+
batch_item.key.precision, no_sync, urlopen_kw={'retries': retry})
|
|
526
537
|
|
|
527
538
|
logger.debug("Write request finished %s", batch_item)
|
|
528
539
|
|
|
529
540
|
return _BatchResponse(data=batch_item)
|
|
530
541
|
|
|
531
|
-
def _post_write(self, _async_req, bucket, org, body, precision, **kwargs):
|
|
542
|
+
def _post_write(self, _async_req, bucket, org, body, precision, no_sync, **kwargs):
|
|
532
543
|
|
|
533
544
|
return self._write_service.post_write(org=org, bucket=bucket, body=body, precision=precision,
|
|
545
|
+
no_sync=no_sync,
|
|
534
546
|
async_req=_async_req,
|
|
535
547
|
content_type="text/plain; charset=utf-8",
|
|
536
548
|
**kwargs)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from influxdb_client_3.write_client.domain import WritePrecision
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class WritePrecisionConverter(object):
|
|
5
|
+
|
|
6
|
+
@staticmethod
|
|
7
|
+
def to_v2_api_string(precision):
|
|
8
|
+
"""
|
|
9
|
+
Converts WritePrecision to its string representation for V2 API.
|
|
10
|
+
"""
|
|
11
|
+
if precision in [WritePrecision.NS, WritePrecision.US, WritePrecision.MS, WritePrecision.S]:
|
|
12
|
+
return precision
|
|
13
|
+
else:
|
|
14
|
+
raise ValueError("Unsupported precision '%s'" % precision)
|
|
15
|
+
|
|
16
|
+
@staticmethod
|
|
17
|
+
def to_v3_api_string(precision):
|
|
18
|
+
"""
|
|
19
|
+
Converts WritePrecision to its string representation for V3 API.
|
|
20
|
+
"""
|
|
21
|
+
if precision == WritePrecision.NS:
|
|
22
|
+
return "nanosecond"
|
|
23
|
+
elif precision == WritePrecision.US:
|
|
24
|
+
return "microsecond"
|
|
25
|
+
elif precision == WritePrecision.MS:
|
|
26
|
+
return "millisecond"
|
|
27
|
+
elif precision == WritePrecision.S:
|
|
28
|
+
return "second"
|
|
29
|
+
else:
|
|
30
|
+
raise ValueError("Unsupported precision '%s'" % precision)
|