Skip to content

feat: remove org from examples code #130

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 2 commits into from
May 2, 2025
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 0 additions & 2 deletions Examples/basic_ssl_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
1 change: 0 additions & 1 deletion Examples/batching_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion Examples/cloud_dedicated_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
client = InfluxDBClient3.InfluxDBClient3(
token=config.token,
host=config.host,
org=config.org,
database=config.database)

table = client.query(
Expand Down
1 change: 0 additions & 1 deletion Examples/cloud_dedicated_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion Examples/community/custom_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 0 additions & 2 deletions Examples/community/database_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion Examples/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 0 additions & 2 deletions Examples/file-import/csv_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ 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
"""
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:
Expand Down
1 change: 0 additions & 1 deletion Examples/file-import/feather_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 0 additions & 2 deletions Examples/file-import/json_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@ 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
"""
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:
Expand Down
1 change: 0 additions & 1 deletion Examples/file-import/orc_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 0 additions & 1 deletion Examples/file-import/parquet_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion Examples/file-import/write_file_parse_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down
1 change: 0 additions & 1 deletion Examples/flight_options_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 0 additions & 1 deletion Examples/handle_http_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def main() -> None:
client = InfluxDBClient3.InfluxDBClient3(
host=config.host,
token=config.token,
org=config.org,
database=config.database
)

Expand Down
1 change: 0 additions & 1 deletion Examples/pandas_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
client = InfluxDBClient3.InfluxDBClient3(
token="",
host="eu-central-1-1.aws.cloud2.influxdata.com",
org="",
database="")


Expand Down
1 change: 0 additions & 1 deletion Examples/pokemon-trainer/basic-query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'''
Expand Down
1 change: 0 additions & 1 deletion Examples/pokemon-trainer/basic-write-errorhandling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion Examples/pokemon-trainer/basic-write-writeoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion Examples/pokemon-trainer/basic-write.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions Examples/pokemon-trainer/cookbook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion Examples/pokemon-trainer/pandas-write.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
1 change: 0 additions & 1 deletion Examples/pokemon-trainer/write-batching.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
1 change: 0 additions & 1 deletion Examples/query_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion Examples/query_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
client = InfluxDBClient3.InfluxDBClient3(
token="",
host="eu-central-1-1.aws.cloud2.influxdata.com",
org="6a841c0c08328fb1",
database="factory")


Expand Down
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
```

Expand Down Expand Up @@ -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:


Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion influxdb_client_3/query/query_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
"""

Expand Down
6 changes: 3 additions & 3 deletions influxdb_client_3/write_client/client/influxdb_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand All @@ -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,
Expand Down
Loading