3
3
from pyarrow import csv
4
4
from pyarrow .flight import FlightClient , Ticket , FlightCallOptions
5
5
from influxdb_client import InfluxDBClient as _InfluxDBClient
6
- from influxdb_client import WriteOptions as _WriteOptions
6
+ from influxdb_client import WriteOptions as WriteOptions
7
7
from influxdb_client .client .write_api import WriteApi as _WriteApi
8
- from influxdb_client .client .write_api import SYNCHRONOUS , ASYNCHRONOUS
9
- from influxdb_client .client .write_api import PointSettings
8
+ from influxdb_client .client .write_api import SYNCHRONOUS , ASYNCHRONOUS , PointSettings
10
9
from influxdb_client .domain .write_precision import WritePrecision
10
+ from influxdb_client .client .exceptions import InfluxDBError
11
11
from influxdb_client import Point
12
12
import json
13
13
14
14
15
- def write_options (** kwargs ):
16
- return _WriteOptions ( ** kwargs )
15
+ def write_client_options (** kwargs ):
16
+ return kwargs
17
17
18
18
19
19
def flight_client_options (** kwargs ):
@@ -27,7 +27,7 @@ def __init__(
27
27
org = None ,
28
28
database = None ,
29
29
token = None ,
30
- write_options = None ,
30
+ write_client_options = None ,
31
31
flight_client_options = None ,
32
32
** kwargs ):
33
33
"""
@@ -36,24 +36,26 @@ def __init__(
36
36
* org (str, optional): The InfluxDB organization name to be used for operations. Defaults to None.
37
37
* database (str, optional): The database to be used for InfluxDB operations. Defaults to None.
38
38
* token (str, optional): The authentication token for accessing the InfluxDB server. Defaults to None.
39
- * write_options (enum , optional): Specifies the write mode (synchronous or asynchronous) to use when writing data points to InfluxDB. Defaults to SYNCHRONOUS .
39
+ * write_options (ANY , optional): Exposes InfuxDB WriteAPI options .
40
40
* **kwargs: Additional arguments to be passed to the InfluxDB Client.
41
41
"""
42
42
self ._org = org
43
43
self ._database = database
44
- self .write_options = write_options if write_options is not None else SYNCHRONOUS
44
+ self .write_client_options = write_client_options if write_client_options is not None else write_client_options ( write_options = SYNCHRONOUS )
45
45
self ._client = _InfluxDBClient (
46
46
url = f"https://{ host } " ,
47
47
token = token ,
48
48
org = self ._org ,
49
49
** kwargs )
50
+
50
51
self ._write_api = _WriteApi (
51
- self ._client , write_options = self .write_options )
52
+ self ._client , ** self .write_client_options )
52
53
53
54
self ._flight_client_options = flight_client_options if flight_client_options is not None else {}
54
55
self ._flight_client = FlightClient (
55
56
f"grpc+tls://{ host } :443" ,
56
57
** self ._flight_client_options )
58
+
57
59
# create an authorization header
58
60
self ._options = FlightCallOptions (
59
61
headers = [(b"authorization" , f"Bearer { token } " .encode ('utf-8' ))])
@@ -140,6 +142,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
140
142
"PointSettings" ,
141
143
"SYNCHRONOUS" ,
142
144
"ASYNCHRONOUS" ,
143
- "write_options " ,
145
+ "write_client_options " ,
144
146
"WritePrecision" ,
145
- "flight_client_options" ]
147
+ "flight_client_options" ,
148
+ "WriteOptions" ]
0 commit comments