influxdb3-python 0.6.0__tar.gz → 0.6.1__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.
Files changed (55) hide show
  1. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/PKG-INFO +1 -1
  2. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb3_python.egg-info/PKG-INFO +1 -1
  3. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb3_python.egg-info/SOURCES.txt +2 -0
  4. influxdb3_python-0.6.1/influxdb_client_3/query/__init__.py +1 -0
  5. influxdb3_python-0.6.1/influxdb_client_3/query/query_api.py +104 -0
  6. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/version.py +1 -1
  7. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/LICENSE +0 -0
  8. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/README.md +0 -0
  9. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb3_python.egg-info/dependency_links.txt +0 -0
  10. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb3_python.egg-info/requires.txt +0 -0
  11. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb3_python.egg-info/top_level.txt +0 -0
  12. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/__init__.py +0 -0
  13. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/py.typed +0 -0
  14. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/read_file.py +0 -0
  15. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/__init__.py +0 -0
  16. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/_sync/__init__.py +0 -0
  17. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/_sync/api_client.py +0 -0
  18. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/_sync/rest.py +0 -0
  19. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/__init__.py +0 -0
  20. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/_base.py +0 -0
  21. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/exceptions.py +0 -0
  22. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/influxdb_client.py +0 -0
  23. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/logging_handler.py +0 -0
  24. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/util/__init__.py +0 -0
  25. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/util/date_utils.py +0 -0
  26. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/util/date_utils_pandas.py +0 -0
  27. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/util/helpers.py +0 -0
  28. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/util/multiprocessing_helper.py +0 -0
  29. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/warnings.py +0 -0
  30. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/write/__init__.py +0 -0
  31. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/write/dataframe_serializer.py +0 -0
  32. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/write/point.py +0 -0
  33. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/write/retry.py +0 -0
  34. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/write_api.py +0 -0
  35. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/configuration.py +0 -0
  36. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/domain/__init__.py +0 -0
  37. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/domain/write_precision.py +0 -0
  38. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/extras.py +0 -0
  39. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/rest.py +0 -0
  40. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/service/__init__.py +0 -0
  41. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/service/_base_service.py +0 -0
  42. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/service/signin_service.py +0 -0
  43. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/service/signout_service.py +0 -0
  44. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/service/write_service.py +0 -0
  45. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/setup.cfg +0 -0
  46. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/setup.py +0 -0
  47. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_api_client.py +0 -0
  48. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_dataframe_serializer.py +0 -0
  49. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_date_helper.py +0 -0
  50. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_deep_merge.py +0 -0
  51. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_influxdb_client_3.py +0 -0
  52. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_influxdb_client_3_integration.py +0 -0
  53. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_merge_options.py +0 -0
  54. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_point.py +0 -0
  55. {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_query.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: influxdb3-python
3
- Version: 0.6.0
3
+ Version: 0.6.1
4
4
  Summary: Community Python client for InfluxDB 3.0
5
5
  Home-page: https://github.com/InfluxCommunity/influxdb3-python
6
6
  Author: InfluxData
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: influxdb3-python
3
- Version: 0.6.0
3
+ Version: 0.6.1
4
4
  Summary: Community Python client for InfluxDB 3.0
5
5
  Home-page: https://github.com/InfluxCommunity/influxdb3-python
6
6
  Author: InfluxData
@@ -10,6 +10,8 @@ influxdb_client_3/__init__.py
10
10
  influxdb_client_3/py.typed
11
11
  influxdb_client_3/read_file.py
12
12
  influxdb_client_3/version.py
13
+ influxdb_client_3/query/__init__.py
14
+ influxdb_client_3/query/query_api.py
13
15
  influxdb_client_3/write_client/__init__.py
14
16
  influxdb_client_3/write_client/configuration.py
15
17
  influxdb_client_3/write_client/extras.py
@@ -0,0 +1 @@
1
+ """Package for query module."""
@@ -0,0 +1,104 @@
1
+ """Query data in InfluxDB 3."""
2
+
3
+ # coding: utf-8
4
+ import json
5
+
6
+ from pyarrow.flight import FlightClient, Ticket, FlightCallOptions, FlightStreamReader
7
+ from influxdb_client_3.version import USER_AGENT
8
+
9
+
10
+ class QueryApi(object):
11
+ """
12
+ Implementation for '/api/v2/query' endpoint.
13
+
14
+ Example:
15
+ .. code-block:: python
16
+
17
+ from influxdb_client import InfluxDBClient
18
+
19
+
20
+ # Initialize instance of QueryApi
21
+ with InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org") as client:
22
+ query_api = client.query_api()
23
+ """
24
+
25
+ def __init__(self,
26
+ connection_string,
27
+ token,
28
+ flight_client_options) -> None:
29
+ """
30
+ Initialize defaults.
31
+
32
+ :param connection_string: Flight/gRPC connection string
33
+ :param token: access token
34
+ :param flight_client_options: Flight client options
35
+ """
36
+ self._token = token
37
+ self._flight_client_options = flight_client_options or {}
38
+ self._flight_client_options["generic_options"] = [
39
+ ("grpc.secondary_user_agent", USER_AGENT)
40
+ ]
41
+ self._flight_client = FlightClient(connection_string, **self._flight_client_options)
42
+
43
+ def query(self, query: str, language: str, mode: str, database: str, **kwargs):
44
+ """Query data from InfluxDB.
45
+
46
+ :param query: The query to execute on the database.
47
+ :param language: The query language.
48
+ :param mode: The mode to use for the query.
49
+ It should be one of "all", "pandas", "polars", "chunk", "reader" or "schema".
50
+ :param database: The database to query from.
51
+ :param kwargs: Additional arguments to pass to the ``FlightCallOptions headers``.
52
+ For example, it can be used to set up per request headers.
53
+ :keyword query_parameters: The query parameters to use in the query.
54
+ It should be a ``dictionary`` of key-value pairs.
55
+ :return: The query result in the specified mode.
56
+ """
57
+ from influxdb_client_3 import polars as has_polars, _merge_options as merge_options
58
+ try:
59
+ # Create an authorization header
60
+ optargs = {
61
+ "headers": [(b"authorization", f"Bearer {self._token}".encode('utf-8'))],
62
+ "timeout": 300
63
+ }
64
+ opts = merge_options(optargs, exclude_keys=['query_parameters'], custom=kwargs)
65
+ _options = FlightCallOptions(**opts)
66
+
67
+ #
68
+ # Ticket data
69
+ #
70
+ ticket_data = {
71
+ "database": database,
72
+ "sql_query": query,
73
+ "query_type": language
74
+ }
75
+ # add query parameters
76
+ query_parameters = kwargs.get("query_parameters", None)
77
+ if query_parameters:
78
+ ticket_data["params"] = query_parameters
79
+
80
+ ticket = Ticket(json.dumps(ticket_data).encode('utf-8'))
81
+ flight_reader = self._do_get(ticket, _options)
82
+
83
+ mode_funcs = {
84
+ "all": flight_reader.read_all,
85
+ "pandas": flight_reader.read_pandas,
86
+ "chunk": lambda: flight_reader,
87
+ "reader": flight_reader.to_reader,
88
+ "schema": lambda: flight_reader.schema
89
+ }
90
+ if has_polars:
91
+ import polars as pl
92
+ mode_funcs["polars"] = lambda: pl.from_arrow(flight_reader.read_all())
93
+ mode_func = mode_funcs.get(mode, flight_reader.read_all)
94
+
95
+ return mode_func() if callable(mode_func) else mode_func
96
+ except Exception as e:
97
+ raise e
98
+
99
+ def _do_get(self, ticket: Ticket, options: FlightCallOptions = None) -> FlightStreamReader:
100
+ return self._flight_client.do_get(ticket, options)
101
+
102
+ def close(self):
103
+ """Close the Flight client."""
104
+ self._flight_client.close()
@@ -1,4 +1,4 @@
1
1
  """Version of the Client that is used in User-Agent header."""
2
2
 
3
- VERSION = '0.6.0'
3
+ VERSION = '0.6.1'
4
4
  USER_AGENT = f'influxdb3-python/{VERSION}'