Skip to content

added flight options #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Examples/flight_options_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import influxdb_client_3 as InfluxDBClient3
import pandas as pd
import numpy as np
from influxdb_client_3 import flight_client_options




with open("./cert.pem", 'rb') as f:
cert = f.read()
print(cert)


client = InfluxDBClient3.InfluxDBClient3(token="",
host="b0c7cce5-8dbc-428e-98c6-7f996fb96467.a.influxdb.io",
org="6a841c0c08328fb1",
database="flightdemo", flight_client_options=flight_client_options(tls_root_certs=cert))


table = client.query(query="SELECT * FROM flight WHERE time > now() - 4h", language="influxql")

print(table.to_pandas())
13 changes: 10 additions & 3 deletions influxdb_client_3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@
def write_options(**kwargs):
return _WriteOptions(**kwargs)

def flight_client_options(**kwargs):
return kwargs # You can replace this with a specific data structure if needed






class InfluxDBClient3:
def __init__(self, host=None, org=None, database=None, token=None, write_options=None, **kwargs):
def __init__(self, host=None, org=None, database=None, token=None, write_options=None, flight_client_options=None ,**kwargs):
"""
This class provides an interface for interacting with an InfluxDB server, simplifying common operations such as writing, querying.
* host (str, optional): The hostname or IP address of the InfluxDB server. Defaults to None.
Expand All @@ -33,7 +38,9 @@ def __init__(self, host=None, org=None, database=None, token=None, write_options
self.write_options = write_options if write_options is not None else SYNCHRONOUS
self._client = _InfluxDBClient(url=f"https://{host}", token=token, org=self._org, **kwargs )
self._write_api = _WriteApi(self._client, write_options=self.write_options )
self._flight_client = FlightClient(f"grpc+tls://{host}:443")

self._flight_client_options = flight_client_options if flight_client_options is not None else {}
self._flight_client = FlightClient(f"grpc+tls://{host}:443", **self._flight_client_options)
# create an authorization header
self._options = FlightCallOptions(headers=[(b"authorization",f"Bearer {token}".encode('utf-8'))])

Expand Down Expand Up @@ -109,4 +116,4 @@ def __enter__(self):
def __exit__(self, exc_type, exc_val, exc_tb):
self.close()

__all__ = ["InfluxDBClient3", "Point", "PointSettings", "SYNCHRONOUS", "ASYNCHRONOUS", "write_options", "WritePrecision"]
__all__ = ["InfluxDBClient3", "Point", "PointSettings", "SYNCHRONOUS", "ASYNCHRONOUS", "write_options", "WritePrecision", "flight_client_options"]