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.
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/PKG-INFO +1 -1
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb3_python.egg-info/PKG-INFO +1 -1
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb3_python.egg-info/SOURCES.txt +2 -0
- influxdb3_python-0.6.1/influxdb_client_3/query/__init__.py +1 -0
- influxdb3_python-0.6.1/influxdb_client_3/query/query_api.py +104 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/version.py +1 -1
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/LICENSE +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/README.md +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb3_python.egg-info/dependency_links.txt +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb3_python.egg-info/requires.txt +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb3_python.egg-info/top_level.txt +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/__init__.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/py.typed +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/read_file.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/__init__.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/_sync/__init__.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/_sync/api_client.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/_sync/rest.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/__init__.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/_base.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/exceptions.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/influxdb_client.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/logging_handler.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/util/__init__.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/util/date_utils.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/util/date_utils_pandas.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/util/helpers.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/util/multiprocessing_helper.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/warnings.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/write/__init__.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/write/dataframe_serializer.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/write/point.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/write/retry.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/write_api.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/configuration.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/domain/__init__.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/domain/write_precision.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/extras.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/rest.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/service/__init__.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/service/_base_service.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/service/signin_service.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/service/signout_service.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/service/write_service.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/setup.cfg +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/setup.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_api_client.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_dataframe_serializer.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_date_helper.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_deep_merge.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_influxdb_client_3.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_influxdb_client_3_integration.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_merge_options.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_point.py +0 -0
- {influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_query.py +0 -0
|
@@ -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()
|
|
File without changes
|
|
File without changes
|
{influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/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
|
{influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/__init__.py
RENAMED
|
File without changes
|
{influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/_sync/__init__.py
RENAMED
|
File without changes
|
{influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/_sync/api_client.py
RENAMED
|
File without changes
|
{influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/_sync/rest.py
RENAMED
|
File without changes
|
{influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/__init__.py
RENAMED
|
File without changes
|
{influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/_base.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
|
{influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/warnings.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/client/write_api.py
RENAMED
|
File without changes
|
{influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/configuration.py
RENAMED
|
File without changes
|
{influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/influxdb_client_3/write_client/domain/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/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
|
{influxdb3_python-0.6.0 → influxdb3_python-0.6.1}/tests/test_influxdb_client_3_integration.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|