influxdb3-python 0.7.0__tar.gz → 0.8.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.7.0 → influxdb3_python-0.8.0}/PKG-INFO +2 -2
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/README.md +1 -1
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb3_python.egg-info/PKG-INFO +2 -2
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb3_python.egg-info/SOURCES.txt +1 -1
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/__init__.py +22 -1
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/version.py +1 -1
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/_base.py +5 -4
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/exceptions.py +11 -1
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/influxdb_client.py +1 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/tests/test_api_client.py +37 -1
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/tests/test_influxdb_client_3.py +21 -0
- influxdb3_python-0.8.0/tests/test_influxdb_client_3_integration.py +58 -0
- influxdb3_python-0.7.0/tests/test_polars_dataframe_serializer.py → influxdb3_python-0.8.0/tests/test_polars.py +34 -2
- influxdb3_python-0.7.0/tests/test_influxdb_client_3_integration.py +0 -45
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/LICENSE +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb3_python.egg-info/dependency_links.txt +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb3_python.egg-info/requires.txt +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb3_python.egg-info/top_level.txt +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/py.typed +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/query/__init__.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/query/query_api.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/read_file.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/__init__.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/_sync/__init__.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/_sync/api_client.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/_sync/rest.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/__init__.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/logging_handler.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/util/__init__.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/util/date_utils.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/util/date_utils_pandas.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/util/helpers.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/util/multiprocessing_helper.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/warnings.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/write/__init__.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/write/dataframe_serializer.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/write/point.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/write/polars_dataframe_serializer.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/write/retry.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/write_api.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/configuration.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/domain/__init__.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/domain/write_precision.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/extras.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/rest.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/service/__init__.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/service/_base_service.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/service/signin_service.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/service/signout_service.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/service/write_service.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/setup.cfg +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/setup.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/tests/test_dataframe_serializer.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/tests/test_date_helper.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/tests/test_deep_merge.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/tests/test_merge_options.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/tests/test_point.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/tests/test_query.py +0 -0
- {influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/tests/test_write_file.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: influxdb3-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.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
|
|
@@ -93,7 +93,7 @@ from influxdb_client_3 import InfluxDBClient3, Point
|
|
|
93
93
|
## Initialization
|
|
94
94
|
If you are using InfluxDB Cloud, then you should note that:
|
|
95
95
|
1. You will need to supply your org id, this is not necessary for InfluxDB Dedicated.
|
|
96
|
-
2. Use
|
|
96
|
+
2. Use bucket name for the `database` argument.
|
|
97
97
|
|
|
98
98
|
```python
|
|
99
99
|
client = InfluxDBClient3(token="your-token",
|
|
@@ -58,7 +58,7 @@ from influxdb_client_3 import InfluxDBClient3, Point
|
|
|
58
58
|
## Initialization
|
|
59
59
|
If you are using InfluxDB Cloud, then you should note that:
|
|
60
60
|
1. You will need to supply your org id, this is not necessary for InfluxDB Dedicated.
|
|
61
|
-
2. Use
|
|
61
|
+
2. Use bucket name for the `database` argument.
|
|
62
62
|
|
|
63
63
|
```python
|
|
64
64
|
client = InfluxDBClient3(token="your-token",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: influxdb3-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.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
|
|
@@ -93,7 +93,7 @@ from influxdb_client_3 import InfluxDBClient3, Point
|
|
|
93
93
|
## Initialization
|
|
94
94
|
If you are using InfluxDB Cloud, then you should note that:
|
|
95
95
|
1. You will need to supply your org id, this is not necessary for InfluxDB Dedicated.
|
|
96
|
-
2. Use
|
|
96
|
+
2. Use bucket name for the `database` argument.
|
|
97
97
|
|
|
98
98
|
```python
|
|
99
99
|
client = InfluxDBClient3(token="your-token",
|
|
@@ -110,7 +110,28 @@ class InfluxDBClient3:
|
|
|
110
110
|
:type write_client_options: callable
|
|
111
111
|
:param flight_client_options: Function for providing additional arguments for the FlightClient.
|
|
112
112
|
:type flight_client_options: callable
|
|
113
|
-
:
|
|
113
|
+
:key auth_scheme: token authentication scheme. Set to "Bearer" for Edge.
|
|
114
|
+
:key bool verify_ssl: Set this to false to skip verifying SSL certificate when calling API from https server.
|
|
115
|
+
:key str ssl_ca_cert: Set this to customize the certificate file to verify the peer.
|
|
116
|
+
:key str cert_file: Path to the certificate that will be used for mTLS authentication.
|
|
117
|
+
:key str cert_key_file: Path to the file contains private key for mTLS certificate.
|
|
118
|
+
:key str cert_key_password: String or function which returns password for decrypting the mTLS private key.
|
|
119
|
+
:key ssl.SSLContext ssl_context: Specify a custom Python SSL Context for the TLS/ mTLS handshake.
|
|
120
|
+
Be aware that only delivered certificate/ key files or an SSL Context are
|
|
121
|
+
possible.
|
|
122
|
+
:key str proxy: Set this to configure the http proxy to be used (ex. http://localhost:3128)
|
|
123
|
+
:key str proxy_headers: A dictionary containing headers that will be sent to the proxy. Could be used for proxy
|
|
124
|
+
authentication.
|
|
125
|
+
:key int connection_pool_maxsize: Number of connections to save that can be reused by urllib3.
|
|
126
|
+
Defaults to "multiprocessing.cpu_count() * 5".
|
|
127
|
+
:key urllib3.util.retry.Retry retries: Set the default retry strategy that is used for all HTTP requests
|
|
128
|
+
except batching writes. As a default there is no one retry strategy.
|
|
129
|
+
:key bool auth_basic: Set this to true to enable basic authentication when talking to a InfluxDB 1.8.x that
|
|
130
|
+
does not use auth-enabled but is protected by a reverse proxy with basic authentication.
|
|
131
|
+
(defaults to false, don't set to true when talking to InfluxDB 2)
|
|
132
|
+
:key str username: ``username`` to authenticate via username and password credentials to the InfluxDB 2.x
|
|
133
|
+
:key str password: ``password`` to authenticate via username and password credentials to the InfluxDB 2.x
|
|
134
|
+
:key list[str] profilers: list of enabled Flux profilers
|
|
114
135
|
"""
|
|
115
136
|
self._org = org if org is not None else "default"
|
|
116
137
|
self._database = database
|
{influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/_base.py
RENAMED
|
@@ -37,7 +37,6 @@ class _BaseClient(object):
|
|
|
37
37
|
def __init__(self, url, token, debug=None, timeout=10_000, enable_gzip=False, org: str = None,
|
|
38
38
|
default_tags: dict = None, http_client_logger: str = None, **kwargs) -> None:
|
|
39
39
|
self.url = url
|
|
40
|
-
self.token = token
|
|
41
40
|
self.org = org
|
|
42
41
|
|
|
43
42
|
self.default_tags = default_tags
|
|
@@ -70,9 +69,10 @@ class _BaseClient(object):
|
|
|
70
69
|
self.auth_header_name = None
|
|
71
70
|
self.auth_header_value = None
|
|
72
71
|
# by token
|
|
73
|
-
if
|
|
72
|
+
if token:
|
|
73
|
+
auth_scheme = kwargs.get('auth_scheme', "Token")
|
|
74
74
|
self.auth_header_name = "Authorization"
|
|
75
|
-
self.auth_header_value = "
|
|
75
|
+
self.auth_header_value = f"{auth_scheme} {token}"
|
|
76
76
|
# by HTTP basic
|
|
77
77
|
auth_basic = kwargs.get('auth_basic', False)
|
|
78
78
|
if auth_basic:
|
|
@@ -248,7 +248,8 @@ class _BaseWriteApi(object):
|
|
|
248
248
|
self._serialize(Point.from_dict(record, write_precision=write_precision, **kwargs),
|
|
249
249
|
write_precision, payload, **kwargs)
|
|
250
250
|
elif 'polars' in str(type(record)):
|
|
251
|
-
from influxdb_client_3.write_client.client.write.
|
|
251
|
+
from influxdb_client_3.write_client.client.write.polars_dataframe_serializer import \
|
|
252
|
+
PolarsDataframeSerializer
|
|
252
253
|
serializer = PolarsDataframeSerializer(record, self._point_settings, write_precision, **kwargs)
|
|
253
254
|
self._serialize(serializer.serialize(), write_precision, payload, **kwargs)
|
|
254
255
|
|
|
@@ -26,8 +26,18 @@ class InfluxDBError(Exception):
|
|
|
26
26
|
# Body
|
|
27
27
|
if response.data:
|
|
28
28
|
import json
|
|
29
|
+
|
|
30
|
+
def get(d, key):
|
|
31
|
+
if not key or d is None:
|
|
32
|
+
return d
|
|
33
|
+
return get(d.get(key[0]), key[1:])
|
|
29
34
|
try:
|
|
30
|
-
|
|
35
|
+
node = json.loads(response.data)
|
|
36
|
+
for key in [['message'], ['data', 'error_message'], ['error']]:
|
|
37
|
+
value = get(node, key)
|
|
38
|
+
if value is not None:
|
|
39
|
+
return value
|
|
40
|
+
return response.data
|
|
31
41
|
except Exception as e:
|
|
32
42
|
logging.debug(f"Cannot parse error response to JSON: {response.data}, {e}")
|
|
33
43
|
return response.data
|
|
@@ -27,6 +27,7 @@ class InfluxDBClient(_BaseClient):
|
|
|
27
27
|
:param enable_gzip: Enable Gzip compression for http requests. Currently, only the "Write" and "Query" endpoints
|
|
28
28
|
supports the Gzip compression.
|
|
29
29
|
:param org: organization name (used as a default in Query, Write and Delete API)
|
|
30
|
+
:key auth_scheme: token authentication scheme. Set to "Bearer" for Edge.
|
|
30
31
|
:key bool verify_ssl: Set this to false to skip verifying SSL certificate when calling API from https server.
|
|
31
32
|
:key str ssl_ca_cert: Set this to customize the certificate file to verify the peer.
|
|
32
33
|
:key str cert_file: Path to the certificate that will be used for mTLS authentication.
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import unittest
|
|
2
2
|
from unittest import mock
|
|
3
|
+
from urllib3 import response
|
|
3
4
|
|
|
4
5
|
from influxdb_client_3.write_client._sync.api_client import ApiClient
|
|
5
6
|
from influxdb_client_3.write_client.configuration import Configuration
|
|
7
|
+
from influxdb_client_3.write_client.client.exceptions import InfluxDBError
|
|
6
8
|
from influxdb_client_3.write_client.service import WriteService
|
|
7
9
|
from influxdb_client_3.version import VERSION
|
|
8
10
|
|
|
9
|
-
|
|
10
11
|
_package = "influxdb3-python"
|
|
11
12
|
_sentHeaders = {}
|
|
12
13
|
|
|
@@ -69,3 +70,38 @@ class ApiClientTests(unittest.TestCase):
|
|
|
69
70
|
self.assertEqual("Bearer TEST_TOKEN", _sentHeaders["Authorization"])
|
|
70
71
|
self.assertIsNotNone(_sentHeaders["User-Agent"])
|
|
71
72
|
self.assertEqual(f"{_package}/{VERSION}", _sentHeaders["User-Agent"])
|
|
73
|
+
|
|
74
|
+
def _test_api_error(self, body):
|
|
75
|
+
conf = Configuration()
|
|
76
|
+
client = ApiClient(conf)
|
|
77
|
+
client.rest_client.pool_manager.request \
|
|
78
|
+
= mock.Mock(return_value=response.HTTPResponse(status=400,
|
|
79
|
+
reason='Bad Request',
|
|
80
|
+
body=body.encode()))
|
|
81
|
+
service = WriteService(client)
|
|
82
|
+
service.post_write("TEST_ORG", "TEST_BUCKET", "data,foo=bar val=3.14")
|
|
83
|
+
|
|
84
|
+
def test_api_error_cloud(self):
|
|
85
|
+
response_body = '{"message": "parsing failed for write_lp endpoint"}'
|
|
86
|
+
with self.assertRaises(InfluxDBError) as err:
|
|
87
|
+
self._test_api_error(response_body)
|
|
88
|
+
self.assertEqual('parsing failed for write_lp endpoint', err.exception.message)
|
|
89
|
+
|
|
90
|
+
def test_api_error_oss_without_detail(self):
|
|
91
|
+
response_body = '{"error": "parsing failed for write_lp endpoint"}'
|
|
92
|
+
with self.assertRaises(InfluxDBError) as err:
|
|
93
|
+
self._test_api_error(response_body)
|
|
94
|
+
self.assertEqual('parsing failed for write_lp endpoint', err.exception.message)
|
|
95
|
+
|
|
96
|
+
def test_api_error_oss_with_detail(self):
|
|
97
|
+
response_body = ('{"error":"parsing failed for write_lp endpoint","data":{"error_message":"invalid field value '
|
|
98
|
+
'in line protocol for field \'val\' on line 1"}}')
|
|
99
|
+
with self.assertRaises(InfluxDBError) as err:
|
|
100
|
+
self._test_api_error(response_body)
|
|
101
|
+
self.assertEqual('invalid field value in line protocol for field \'val\' on line 1', err.exception.message)
|
|
102
|
+
|
|
103
|
+
def test_api_error_unknown(self):
|
|
104
|
+
response_body = '{"detail":"no info"}'
|
|
105
|
+
with self.assertRaises(InfluxDBError) as err:
|
|
106
|
+
self._test_api_error(response_body)
|
|
107
|
+
self.assertEqual(response_body, err.exception.message)
|
|
@@ -27,6 +27,27 @@ class TestInfluxDBClient3(unittest.TestCase):
|
|
|
27
27
|
self.assertEqual(self.client._write_api, self.mock_write_api.return_value)
|
|
28
28
|
self.assertEqual(self.client._query_api, self.mock_query_api.return_value)
|
|
29
29
|
|
|
30
|
+
# test default token auth_scheme
|
|
31
|
+
def test_token_auth_scheme_default(self):
|
|
32
|
+
client = InfluxDBClient3(
|
|
33
|
+
host="localhost",
|
|
34
|
+
org="my_org",
|
|
35
|
+
database="my_db",
|
|
36
|
+
token="my_token",
|
|
37
|
+
)
|
|
38
|
+
self.assertEqual(client._client.auth_header_value, "Token my_token")
|
|
39
|
+
|
|
40
|
+
# test explicit token auth_scheme
|
|
41
|
+
def test_token_auth_scheme_explicit(self):
|
|
42
|
+
client = InfluxDBClient3(
|
|
43
|
+
host="localhost",
|
|
44
|
+
org="my_org",
|
|
45
|
+
database="my_db",
|
|
46
|
+
token="my_token",
|
|
47
|
+
auth_scheme="my_scheme"
|
|
48
|
+
)
|
|
49
|
+
self.assertEqual(client._client.auth_header_value, "my_scheme my_token")
|
|
50
|
+
|
|
30
51
|
|
|
31
52
|
if __name__ == '__main__':
|
|
32
53
|
unittest.main()
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import time
|
|
3
|
+
import unittest
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
from influxdb_client_3 import InfluxDBClient3, InfluxDBError
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.mark.integration
|
|
11
|
+
@pytest.mark.skipif(
|
|
12
|
+
not all(
|
|
13
|
+
[
|
|
14
|
+
os.getenv('TESTING_INFLUXDB_URL'),
|
|
15
|
+
os.getenv('TESTING_INFLUXDB_TOKEN'),
|
|
16
|
+
os.getenv('TESTING_INFLUXDB_DATABASE'),
|
|
17
|
+
]
|
|
18
|
+
),
|
|
19
|
+
reason="Integration test environment variables not set.",
|
|
20
|
+
)
|
|
21
|
+
class TestInfluxDBClient3Integration(unittest.TestCase):
|
|
22
|
+
|
|
23
|
+
def setUp(self):
|
|
24
|
+
self.host = os.getenv('TESTING_INFLUXDB_URL')
|
|
25
|
+
self.token = os.getenv('TESTING_INFLUXDB_TOKEN')
|
|
26
|
+
self.database = os.getenv('TESTING_INFLUXDB_DATABASE')
|
|
27
|
+
self.client = InfluxDBClient3(host=self.host, database=self.database, token=self.token)
|
|
28
|
+
|
|
29
|
+
def tearDown(self):
|
|
30
|
+
if self.client:
|
|
31
|
+
self.client.close()
|
|
32
|
+
|
|
33
|
+
def test_write_and_query(self):
|
|
34
|
+
test_id = time.time_ns()
|
|
35
|
+
self.client.write(f"integration_test_python,type=used value=123.0,test_id={test_id}i")
|
|
36
|
+
|
|
37
|
+
sql = 'SELECT * FROM integration_test_python where type=$type and test_id=$test_id'
|
|
38
|
+
|
|
39
|
+
df = self.client.query(sql, mode="pandas", query_parameters={'type': 'used', 'test_id': test_id})
|
|
40
|
+
|
|
41
|
+
self.assertIsNotNone(df)
|
|
42
|
+
self.assertEqual(1, len(df))
|
|
43
|
+
self.assertEqual(test_id, df['test_id'][0])
|
|
44
|
+
self.assertEqual(123.0, df['value'][0])
|
|
45
|
+
|
|
46
|
+
def test_auth_error_token(self):
|
|
47
|
+
self.client = InfluxDBClient3(host=self.host, database=self.database, token='fake token')
|
|
48
|
+
test_id = time.time_ns()
|
|
49
|
+
with self.assertRaises(InfluxDBError) as err:
|
|
50
|
+
self.client.write(f"integration_test_python,type=used value=123.0,test_id={test_id}i")
|
|
51
|
+
self.assertEqual('unauthorized access', err.exception.message) # Cloud
|
|
52
|
+
|
|
53
|
+
def test_auth_error_auth_scheme(self):
|
|
54
|
+
self.client = InfluxDBClient3(host=self.host, database=self.database, token=self.token, auth_scheme='Any')
|
|
55
|
+
test_id = time.time_ns()
|
|
56
|
+
with self.assertRaises(InfluxDBError) as err:
|
|
57
|
+
self.client.write(f"integration_test_python,type=used value=123.0,test_id={test_id}i")
|
|
58
|
+
self.assertEqual('unauthorized access', err.exception.message) # Cloud
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import unittest
|
|
2
1
|
import importlib.util
|
|
2
|
+
import unittest
|
|
3
|
+
from unittest.mock import Mock
|
|
3
4
|
|
|
4
|
-
from influxdb_client_3 import PointSettings
|
|
5
|
+
from influxdb_client_3 import PointSettings, InfluxDBClient3
|
|
6
|
+
from influxdb_client_3.write_client import WriteService
|
|
5
7
|
from influxdb_client_3.write_client.client.write.polars_dataframe_serializer import polars_data_frame_to_list_of_points
|
|
6
8
|
|
|
7
9
|
|
|
@@ -29,3 +31,33 @@ class TestPolarsDataFrameSerializer(unittest.TestCase):
|
|
|
29
31
|
'iot-devices,building=5a name="iot-devices",temperature=72.2 1664798460000000000'
|
|
30
32
|
]
|
|
31
33
|
self.assertEqual(expected, actual)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@unittest.skipIf(importlib.util.find_spec("polars") is None, 'Polars package not installed')
|
|
37
|
+
class TestWritePolars(unittest.TestCase):
|
|
38
|
+
def setUp(self):
|
|
39
|
+
self.client = InfluxDBClient3(
|
|
40
|
+
host="localhost",
|
|
41
|
+
org="my_org",
|
|
42
|
+
database="my_db",
|
|
43
|
+
token="my_token"
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
def test_write_polars(self):
|
|
47
|
+
import polars as pl
|
|
48
|
+
df = pl.DataFrame({
|
|
49
|
+
"time": pl.Series(["2024-08-01 00:00:00", "2024-08-01 01:00:00"]).str.to_datetime(time_unit='ns'),
|
|
50
|
+
"temperature": [22.4, 21.8],
|
|
51
|
+
})
|
|
52
|
+
self.client._write_api._write_service = Mock(spec=WriteService)
|
|
53
|
+
|
|
54
|
+
self.client.write(
|
|
55
|
+
database="database",
|
|
56
|
+
record=df,
|
|
57
|
+
data_frame_measurement_name="measurement",
|
|
58
|
+
data_frame_timestamp_column="time",
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
actual = self.client._write_api._write_service.post_write.call_args[1]['body']
|
|
62
|
+
self.assertEqual(b'measurement temperature=22.4 1722470400000000000\n'
|
|
63
|
+
b'measurement temperature=21.8 1722474000000000000', actual)
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import time
|
|
3
|
-
import unittest
|
|
4
|
-
|
|
5
|
-
import pytest
|
|
6
|
-
|
|
7
|
-
from influxdb_client_3 import InfluxDBClient3
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@pytest.mark.integration
|
|
11
|
-
@pytest.mark.skipif(
|
|
12
|
-
not all(
|
|
13
|
-
[
|
|
14
|
-
os.getenv('TESTING_INFLUXDB_URL'),
|
|
15
|
-
os.getenv('TESTING_INFLUXDB_TOKEN'),
|
|
16
|
-
os.getenv('TESTING_INFLUXDB_DATABASE'),
|
|
17
|
-
]
|
|
18
|
-
),
|
|
19
|
-
reason="Integration test environment variables not set.",
|
|
20
|
-
)
|
|
21
|
-
class TestInfluxDBClient3Integration(unittest.TestCase):
|
|
22
|
-
|
|
23
|
-
def setUp(self):
|
|
24
|
-
host = os.getenv('TESTING_INFLUXDB_URL')
|
|
25
|
-
token = os.getenv('TESTING_INFLUXDB_TOKEN')
|
|
26
|
-
database = os.getenv('TESTING_INFLUXDB_DATABASE')
|
|
27
|
-
|
|
28
|
-
self.client = InfluxDBClient3(host=host, database=database, token=token)
|
|
29
|
-
|
|
30
|
-
def tearDown(self):
|
|
31
|
-
if self.client:
|
|
32
|
-
self.client.close()
|
|
33
|
-
|
|
34
|
-
def test_write_and_query(self):
|
|
35
|
-
test_id = time.time_ns()
|
|
36
|
-
self.client.write(f"integration_test_python,type=used value=123.0,test_id={test_id}i")
|
|
37
|
-
|
|
38
|
-
sql = 'SELECT * FROM integration_test_python where type=$type and test_id=$test_id'
|
|
39
|
-
|
|
40
|
-
df = self.client.query(sql, mode="pandas", query_parameters={'type': 'used', 'test_id': test_id})
|
|
41
|
-
|
|
42
|
-
self.assertIsNotNone(df)
|
|
43
|
-
self.assertEqual(1, len(df))
|
|
44
|
-
self.assertEqual(test_id, df['test_id'][0])
|
|
45
|
-
self.assertEqual(123.0, df['value'][0])
|
|
File without changes
|
{influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb3_python.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/__init__.py
RENAMED
|
File without changes
|
{influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/_sync/__init__.py
RENAMED
|
File without changes
|
{influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/_sync/api_client.py
RENAMED
|
File without changes
|
{influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/_sync/rest.py
RENAMED
|
File without changes
|
{influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/warnings.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/client/write_api.py
RENAMED
|
File without changes
|
{influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/configuration.py
RENAMED
|
File without changes
|
{influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/domain/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{influxdb3_python-0.7.0 → influxdb3_python-0.8.0}/influxdb_client_3/write_client/service/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|