From 9e098b0b20287ba9df8d617d177bbe06b678efcb Mon Sep 17 00:00:00 2001 From: NguyenHoangSon96 Date: Tue, 29 Apr 2025 17:37:20 +0700 Subject: [PATCH 1/2] wip --- Examples/basic_ssl_example.py | 2 -- Examples/batching_example.py | 1 - Examples/cloud_dedicated_query.py | 1 - Examples/cloud_dedicated_write.py | 1 - Examples/community/custom_url.py | 1 - Examples/community/database_transfer.py | 2 -- Examples/config.py | 1 - Examples/file-import/csv_write.py | 2 -- Examples/file-import/feather_write.py | 1 - Examples/file-import/json_write.py | 2 -- Examples/file-import/orc_write.py | 1 - Examples/file-import/parquet_write.py | 1 - Examples/file-import/write_file_parse_options.py | 1 - Examples/flight_options_example.py | 1 - Examples/handle_http_error.py | 1 - Examples/pandas_write.py | 1 - Examples/pokemon-trainer/basic-query.py | 1 - .../pokemon-trainer/basic-write-errorhandling.py | 1 - .../pokemon-trainer/basic-write-writeoptions.py | 1 - Examples/pokemon-trainer/basic-write.py | 1 - Examples/pokemon-trainer/cookbook.ipynb | 3 +-- Examples/pokemon-trainer/pandas-write.py | 1 - .../write-batching-flight-calloptions.py | 2 +- Examples/pokemon-trainer/write-batching.py | 1 - Examples/query_async.py | 1 - Examples/query_type.py | 1 - README.md | 14 ++++---------- influxdb_client_3/query/query_api.py | 2 +- .../write_client/client/influxdb_client.py | 6 +++--- 29 files changed, 10 insertions(+), 45 deletions(-) diff --git a/Examples/basic_ssl_example.py b/Examples/basic_ssl_example.py index 98096c9..1667f78 100644 --- a/Examples/basic_ssl_example.py +++ b/Examples/basic_ssl_example.py @@ -70,7 +70,6 @@ def write_and_query_with_explicit_sys_cert(conf): print("\nwrite and query with typical linux system cert\n") with InfluxDBClient3(token=conf.token, host=conf.host, - org=conf.org, database=conf.database, ssl_ca_cert="/etc/ssl/certs/ca-certificates.crt", verify_ssl=True) as _client: @@ -90,7 +89,6 @@ def query_with_verify_ssl_off(conf, cert): # Switch verify_ssl to True to throw SSL_ERROR_SSL with InfluxDBClient3(token=conf.token, host=conf.host, - org=conf.org, database=conf.database, ssl_ca_cert=cert, verify_ssl=False) as _client: diff --git a/Examples/batching_example.py b/Examples/batching_example.py index e0ec8df..87f907e 100644 --- a/Examples/batching_example.py +++ b/Examples/batching_example.py @@ -70,7 +70,6 @@ def main() -> None: # of 10k ms and gzip compression with InfluxDBClient3.InfluxDBClient3(token=conf.token, host=conf.host, - org=conf.org, database=conf.database, enable_gzip=True, write_client_options=wco) as _client: diff --git a/Examples/cloud_dedicated_query.py b/Examples/cloud_dedicated_query.py index db1ca81..38e5ae7 100644 --- a/Examples/cloud_dedicated_query.py +++ b/Examples/cloud_dedicated_query.py @@ -6,7 +6,6 @@ client = InfluxDBClient3.InfluxDBClient3( token=config.token, host=config.host, - org=config.org, database=config.database) table = client.query( diff --git a/Examples/cloud_dedicated_write.py b/Examples/cloud_dedicated_write.py index aacedee..f51422e 100644 --- a/Examples/cloud_dedicated_write.py +++ b/Examples/cloud_dedicated_write.py @@ -9,7 +9,6 @@ client = InfluxDBClient3.InfluxDBClient3( token=config.token, host=config.host, - org=config.org, database=config.database, write_options=WriteOptions( batch_size=500, diff --git a/Examples/community/custom_url.py b/Examples/community/custom_url.py index 4652115..e356334 100644 --- a/Examples/community/custom_url.py +++ b/Examples/community/custom_url.py @@ -36,7 +36,6 @@ def retry(self, conf, data: str, exception: InfluxDBError): client = InfluxDBClient3( token="", host="https://eu-central-1-1.aws.cloud2.influxdata.com:442", - org="6a841c0c08328fb1", database="pokemon-codex", enable_gzip=True, write_client_options=wco, write_port_overwrite=443, query_port_overwrite=443) diff --git a/Examples/community/database_transfer.py b/Examples/community/database_transfer.py index b001a0d..478532b 100644 --- a/Examples/community/database_transfer.py +++ b/Examples/community/database_transfer.py @@ -18,7 +18,6 @@ def retry(self, conf, data: str, exception: InfluxDBError): # InfluxDB connection details token = "" -org = "6a841c0c08328fb1" dbfrom = "a" dbto = "b" url = "eu-central-1-1.aws.cloud2.influxdata.com" @@ -44,7 +43,6 @@ def retry(self, conf, data: str, exception: InfluxDBError): # of 10k ms and gzip compression with InfluxDBClient3.InfluxDBClient3(token=token, host=url, - org=org, enable_gzip=True, write_client_options=wco) as _client: query = f"SHOW TAG KEYS FROM {measurement}" tags = _client.query(query=query, language="influxql", database=dbfrom) diff --git a/Examples/config.py b/Examples/config.py index 9888d9b..5ab1b49 100644 --- a/Examples/config.py +++ b/Examples/config.py @@ -6,7 +6,6 @@ class Config: def __init__(self): self.host = os.getenv('INFLUXDB_HOST') or 'https://us-east-1-1.aws.cloud2.influxdata.com/' self.token = os.getenv('INFLUXDB_TOKEN') or 'my-token' - self.org = os.getenv('INFLUXDB_ORG') or 'my-org' self.database = os.getenv('INFLUXDB_DATABASE') or 'my-db' def __str__(self): diff --git a/Examples/file-import/csv_write.py b/Examples/file-import/csv_write.py index 2c6ed44..7928d30 100644 --- a/Examples/file-import/csv_write.py +++ b/Examples/file-import/csv_write.py @@ -43,7 +43,6 @@ def main() -> None: """ token: access token generated in cloud host: ATTN could be another AWS region or even another cloud provider - org: organization associated with account and database database: should have retention policy 'forever' to handle older sample data timestamps write_client_options: see above debug: allows low-level inspection of communications and context-manager termination @@ -51,7 +50,6 @@ def main() -> None: with InfluxDBClient3.InfluxDBClient3( token="INSERT_TOKEN", host="https://us-east-1-1.aws.cloud2.influxdata.com/", - org="INSERT_ORG", database="example_data_forever", write_client_options=wco, debug=True) as client: diff --git a/Examples/file-import/feather_write.py b/Examples/file-import/feather_write.py index 0e5c4a6..d931ca9 100644 --- a/Examples/file-import/feather_write.py +++ b/Examples/file-import/feather_write.py @@ -33,7 +33,6 @@ def retry(self, conf, data: str, exception: InfluxDBError): with InfluxDBClient3.InfluxDBClient3( token="INSERT_TOKEN", host="eu-central-1-1.aws.cloud2.influxdata.com", - org="6a841c0c08328fb1", database="python", write_client_options=wco) as client: client.write_file( file='./out.feather', diff --git a/Examples/file-import/json_write.py b/Examples/file-import/json_write.py index 37e8a1c..c259bd3 100644 --- a/Examples/file-import/json_write.py +++ b/Examples/file-import/json_write.py @@ -42,7 +42,6 @@ def main() -> None: """ token: access token generated in cloud host: ATTN could be another AWS region or even another cloud provider - org: organization associated with account and database database: should have retention policy 'forever' to handle older sample data timestamps write_client_options: see above debug: allows low-level inspection of communications and context-manager termination @@ -50,7 +49,6 @@ def main() -> None: with InfluxDBClient3.InfluxDBClient3( token="INSERT_TOKEN", host="https://us-east-1-1.aws.cloud2.influxdata.com/", - org="INSERT_ORG", database="example_data_forever", write_client_options=wco, debug=True) as client: diff --git a/Examples/file-import/orc_write.py b/Examples/file-import/orc_write.py index 9ce7b38..67581c5 100644 --- a/Examples/file-import/orc_write.py +++ b/Examples/file-import/orc_write.py @@ -33,7 +33,6 @@ def retry(self, conf, data: str, exception: InfluxDBError): with InfluxDBClient3.InfluxDBClient3( token="INSERT_TOKEN", host="eu-central-1-1.aws.cloud2.influxdata.com", - org="6a841c0c08328fb1", database="python") as client: client.write_file( file='./out.orc', diff --git a/Examples/file-import/parquet_write.py b/Examples/file-import/parquet_write.py index e6e00ae..b7a3c70 100644 --- a/Examples/file-import/parquet_write.py +++ b/Examples/file-import/parquet_write.py @@ -33,7 +33,6 @@ def retry(self, conf, data: str, exception: InfluxDBError): with InfluxDBClient3.InfluxDBClient3( token="INSERT_TOKEN", host="eu-central-1-1.aws.cloud2.influxdata.com", - org="6a841c0c08328fb1", database="python", write_client_options=wco) as client: client.write_file( diff --git a/Examples/file-import/write_file_parse_options.py b/Examples/file-import/write_file_parse_options.py index cb1ec37..282a9cc 100644 --- a/Examples/file-import/write_file_parse_options.py +++ b/Examples/file-import/write_file_parse_options.py @@ -33,7 +33,6 @@ def retry(self, conf, data: str, exception: InfluxDBError): with InfluxDBClient3.InfluxDBClient3( token="", host="eu-central-1-1.aws.cloud2.influxdata.com", - org="6a841c0c08328fb1", database="python", write_client_options=wco) as client: fpo = file_parser_options(columns=["time", "machineID", "vibration"]) diff --git a/Examples/flight_options_example.py b/Examples/flight_options_example.py index aa1bba9..d30470d 100644 --- a/Examples/flight_options_example.py +++ b/Examples/flight_options_example.py @@ -10,7 +10,6 @@ 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)) diff --git a/Examples/handle_http_error.py b/Examples/handle_http_error.py index 9ca5e1b..fd0571f 100644 --- a/Examples/handle_http_error.py +++ b/Examples/handle_http_error.py @@ -18,7 +18,6 @@ def main() -> None: client = InfluxDBClient3.InfluxDBClient3( host=config.host, token=config.token, - org=config.org, database=config.database ) diff --git a/Examples/pandas_write.py b/Examples/pandas_write.py index 76f992d..ead33cc 100644 --- a/Examples/pandas_write.py +++ b/Examples/pandas_write.py @@ -5,7 +5,6 @@ client = InfluxDBClient3.InfluxDBClient3( token="", host="eu-central-1-1.aws.cloud2.influxdata.com", - org="", database="") diff --git a/Examples/pokemon-trainer/basic-query.py b/Examples/pokemon-trainer/basic-query.py index 0c38be7..08b50ba 100644 --- a/Examples/pokemon-trainer/basic-query.py +++ b/Examples/pokemon-trainer/basic-query.py @@ -3,7 +3,6 @@ client = InfluxDBClient3( token="", host="eu-central-1-1.aws.cloud2.influxdata.com", - org="6a841c0c08328fb1", database="pokemon-codex") sql = '''SELECT * FROM caught WHERE trainer = 'ash' AND time >= now() - interval '1 hour' LIMIT 5''' diff --git a/Examples/pokemon-trainer/basic-write-errorhandling.py b/Examples/pokemon-trainer/basic-write-errorhandling.py index ded6dfd..14be2c9 100644 --- a/Examples/pokemon-trainer/basic-write-errorhandling.py +++ b/Examples/pokemon-trainer/basic-write-errorhandling.py @@ -7,7 +7,6 @@ with InfluxDBClient3( token="", host="eu-central-1-1.aws.cloud2.influxdata.com", - org="6a841c0c08328fb1", database="pokemon-codex", write_client_options=wco) as client: now = datetime.datetime.now(datetime.timezone.utc) diff --git a/Examples/pokemon-trainer/basic-write-writeoptions.py b/Examples/pokemon-trainer/basic-write-writeoptions.py index fcca6a4..97bc399 100644 --- a/Examples/pokemon-trainer/basic-write-writeoptions.py +++ b/Examples/pokemon-trainer/basic-write-writeoptions.py @@ -7,7 +7,6 @@ with InfluxDBClient3( token="", host="eu-central-1-1.aws.cloud2.influxdata.com", - org="6a841c0c08328fb1", database="pokemon-codex", write_client_options=wco, debug=True) as client: diff --git a/Examples/pokemon-trainer/basic-write.py b/Examples/pokemon-trainer/basic-write.py index 2067dfc..ee91797 100644 --- a/Examples/pokemon-trainer/basic-write.py +++ b/Examples/pokemon-trainer/basic-write.py @@ -5,7 +5,6 @@ client = InfluxDBClient3( token="mGbL-OJ2kxYqvbIL9jQOOg2VJLhf16hh-xn-XJe3RUKrI5cewOAy80L5cVIzG0vh7dLLckZkpYfvExgoMBXLFA==", host="eu-central-1-1.aws.cloud2.influxdata.com", - org="6a841c0c08328fb1", database="pokemon-codex") now = datetime.datetime.now(datetime.timezone.utc) diff --git a/Examples/pokemon-trainer/cookbook.ipynb b/Examples/pokemon-trainer/cookbook.ipynb index 7af0fe9..caa956a 100644 --- a/Examples/pokemon-trainer/cookbook.ipynb +++ b/Examples/pokemon-trainer/cookbook.ipynb @@ -95,12 +95,11 @@ "source": [ "# In this example we are using the InfluxDBClient3 object to connect to the InfluxDB Cloud instance.\n", "# We are also passing in the write_client_options we created earlier.\n", - "# The token, host and org are all required to connect to the InfluxDB Serverless instance.\n", + "# The token and host are required to connect to the InfluxDB Serverless instance.\n", "# Note: that Org is optional with Dedicated instances.\n", "client = InfluxDBClient3(\n", " token=\"phVXVXPBZ12vyNvVGJJX6vngFa4zyCYIzgDTYRJsPyIUSi3r78agctL2ksCH1GlUxtIWdGFWL5ScxQxUnbQOAQ==\",\n", " host=\"eu-central-1-1.aws.cloud2.influxdata.com\",\n", - " org=\"6a841c0c08328fb1\",\n", " database=\"pokemon-codex\", enable_gzip=True, write_client_options=wco)\n", "\n", "now = pd.Timestamp.now(tz='UTC').floor('ms')\n", diff --git a/Examples/pokemon-trainer/pandas-write.py b/Examples/pokemon-trainer/pandas-write.py index a4fe194..76f57e0 100644 --- a/Examples/pokemon-trainer/pandas-write.py +++ b/Examples/pokemon-trainer/pandas-write.py @@ -7,7 +7,6 @@ client = InfluxDBClient3( token="", host="eu-central-1-1.aws.cloud2.influxdata.com", - org="6a841c0c08328fb1", database="pokemon-codex") now = pd.Timestamp.now(tz='UTC').floor('ms') diff --git a/Examples/pokemon-trainer/write-batching-flight-calloptions.py b/Examples/pokemon-trainer/write-batching-flight-calloptions.py index f8f8bb0..6f3b87f 100644 --- a/Examples/pokemon-trainer/write-batching-flight-calloptions.py +++ b/Examples/pokemon-trainer/write-batching-flight-calloptions.py @@ -39,7 +39,7 @@ def retry(self, conf, data: str, exception: InfluxDBError): client = InfluxDBClient3( token="", host="eu-central-1-1.aws.cloud2.influxdata.com", - org="6a841c0c08328fb1", enable_gzip=True, write_client_options=wco) + enable_gzip=True, write_client_options=wco) now = pd.Timestamp.now(tz='UTC').floor('ms') diff --git a/Examples/pokemon-trainer/write-batching.py b/Examples/pokemon-trainer/write-batching.py index 7891fe5..f6fa180 100644 --- a/Examples/pokemon-trainer/write-batching.py +++ b/Examples/pokemon-trainer/write-batching.py @@ -36,7 +36,6 @@ def retry(self, conf, data: str, exception: InfluxDBError): client = InfluxDBClient3( token="", host="eu-central-1-1.aws.cloud2.influxdata.com", - org="6a841c0c08328fb1", database="pokemon-codex", enable_gzip=True, write_client_options=wco) now = pd.Timestamp.now(tz='UTC').floor('ms') diff --git a/Examples/query_async.py b/Examples/query_async.py index f6079f5..77bff4b 100644 --- a/Examples/query_async.py +++ b/Examples/query_async.py @@ -72,7 +72,6 @@ async def main(): host=config.host, token=config.token, database=config.database, - org=config.org ) measurement = 'example_uav' write_data(client, measurement) diff --git a/Examples/query_type.py b/Examples/query_type.py index e9b28ae..4a37b7a 100644 --- a/Examples/query_type.py +++ b/Examples/query_type.py @@ -3,7 +3,6 @@ client = InfluxDBClient3.InfluxDBClient3( token="", host="eu-central-1-1.aws.cloud2.influxdata.com", - org="6a841c0c08328fb1", database="factory") diff --git a/README.md b/README.md index c4df8eb..10981d0 100644 --- a/README.md +++ b/README.md @@ -57,13 +57,11 @@ from influxdb_client_3 import InfluxDBClient3, Point ## Initialization If you are using InfluxDB Cloud, then you should note that: -1. You will need to supply your org id, this is not necessary for InfluxDB Dedicated. -2. Use bucket name for the `database` argument. +1. Use bucket name for the `database` argument. ```python client = InfluxDBClient3(token="your-token", host="your-host", - org="your-org", database="your-database") ``` @@ -124,7 +122,6 @@ wco = write_client_options(success_callback=callback.success, with InfluxDBClient3.InfluxDBClient3( token="INSERT_TOKEN", host="eu-central-1-1.aws.cloud2.influxdata.com", - org="6a841c0c08328fb1", database="python", write_client_options=wco) as client: @@ -171,27 +168,24 @@ Install `certifi` pip install certifi ``` Next include certifi within the flight client options: + ```python +import certifi + import influxdb_client_3 as InfluxDBClient3 -import pandas as pd -import numpy as np from influxdb_client_3 import flight_client_options -import certifi fh = open(certifi.where(), "r") cert = fh.read() fh.close() - 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") diff --git a/influxdb_client_3/query/query_api.py b/influxdb_client_3/query/query_api.py index 679803e..24ca60f 100644 --- a/influxdb_client_3/query/query_api.py +++ b/influxdb_client_3/query/query_api.py @@ -104,7 +104,7 @@ class QueryApi(object): # Initialize instance of QueryApi - with InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org") as client: + with InfluxDBClient(url="http://localhost:8086", token="my-token") as client: query_api = client.query_api() """ diff --git a/influxdb_client_3/write_client/client/influxdb_client.py b/influxdb_client_3/write_client/client/influxdb_client.py index e377b2a..3dd29af 100644 --- a/influxdb_client_3/write_client/client/influxdb_client.py +++ b/influxdb_client_3/write_client/client/influxdb_client.py @@ -212,7 +212,7 @@ def write_api(self, write_options=WriteOptions(), point_settings=PointSettings() # Initialize SYNCHRONOUS instance of WriteApi - with InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org") as client: + with InfluxDBClient(url="http://localhost:8086", token="my-token") as client: write_api = client.write_api(write_options=SYNCHRONOUS) If you would like to use a **background batching**, you have to configure client like this: @@ -222,7 +222,7 @@ def write_api(self, write_options=WriteOptions(), point_settings=PointSettings() from influxdb_client import InfluxDBClient # Initialize background batching instance of WriteApi - with InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org") as client: + with InfluxDBClient(url="http://localhost:8086", token="my-token") as client: with client.write_api() as write_api: pass @@ -246,7 +246,7 @@ def retry(self, conf: (str, str, str), data: str, exception: InfluxDBError): print(f"Retryable error occurs for batch: {conf}, data: {data} retry: {exception}") - with InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org") as client: + with InfluxDBClient(url="http://localhost:8086", token="my-token") as client: callback = BatchingCallback() with client.write_api(success_callback=callback.success, error_callback=callback.error, From c824711d0ae5907940fbacf16592c766629fdcc9 Mon Sep 17 00:00:00 2001 From: NguyenHoangSon96 Date: Tue, 29 Apr 2025 17:44:01 +0700 Subject: [PATCH 2/2] wip --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 896e452..4146ecf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.13.0 [unreleased] +### Features + +1. [#130](https://github.com/InfluxCommunity/influxdb3-python/pull/130): Remove org parameters from the example code because It is not mandatory in Influxdb3 ## 0.12.0 [2025-03-26]