33from pyarrow import csv
44from pyarrow .flight import FlightClient , Ticket , FlightCallOptions
55from influxdb_client import InfluxDBClient as _InfluxDBClient
6- from influxdb_client import WriteOptions as _WriteOptions
6+ from influxdb_client import WriteOptions as WriteOptions
77from 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
109from influxdb_client .domain .write_precision import WritePrecision
10+ from influxdb_client .client .exceptions import InfluxDBError
1111from influxdb_client import Point
1212import json
1313
1414
15- def write_options (** kwargs ):
16- return _WriteOptions ( ** kwargs )
15+ def write_client_options (** kwargs ):
16+ return kwargs
1717
1818
1919def flight_client_options (** kwargs ):
@@ -27,7 +27,7 @@ def __init__(
2727 org = None ,
2828 database = None ,
2929 token = None ,
30- write_options = None ,
30+ write_client_options = None ,
3131 flight_client_options = None ,
3232 ** kwargs ):
3333 """
@@ -36,24 +36,26 @@ def __init__(
3636 * org (str, optional): The InfluxDB organization name to be used for operations. Defaults to None.
3737 * database (str, optional): The database to be used for InfluxDB operations. Defaults to None.
3838 * 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 .
4040 * **kwargs: Additional arguments to be passed to the InfluxDB Client.
4141 """
4242 self ._org = org
4343 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 )
4545 self ._client = _InfluxDBClient (
4646 url = f"https://{ host } " ,
4747 token = token ,
4848 org = self ._org ,
4949 ** kwargs )
50+
5051 self ._write_api = _WriteApi (
51- self ._client , write_options = self .write_options )
52+ self ._client , ** self .write_client_options )
5253
5354 self ._flight_client_options = flight_client_options if flight_client_options is not None else {}
5455 self ._flight_client = FlightClient (
5556 f"grpc+tls://{ host } :443" ,
5657 ** self ._flight_client_options )
58+
5759 # create an authorization header
5860 self ._options = FlightCallOptions (
5961 headers = [(b"authorization" , f"Bearer { token } " .encode ('utf-8' ))])
@@ -140,6 +142,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
140142 "PointSettings" ,
141143 "SYNCHRONOUS" ,
142144 "ASYNCHRONOUS" ,
143- "write_options " ,
145+ "write_client_options " ,
144146 "WritePrecision" ,
145- "flight_client_options" ]
147+ "flight_client_options" ,
148+ "WriteOptions" ]
0 commit comments