Skip to content

Commit

Permalink
docs: Clarify how to use a client with InfluxDB 1.8 (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
bednar authored Apr 16, 2020
1 parent 953686c commit d6ba893
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 7 deletions.
15 changes: 8 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

### Documentation
1. [#75](https://github.com/influxdata/influxdb-client-python/issues/75): Updated docs to clarify how to use an org parameter
1. [#84](https://github.com/influxdata/influxdb-client-python/pull/84): Clarify how to use a client with InfluxDB 1.8

### Bugs
### Bug Fixes
1. [#72](https://github.com/influxdata/influxdb-client-python/issues/72): Optimize serializing data into Pandas DataFrame

## 1.5.0 [2020-03-13]

### Features
1. [#59](https://github.com/influxdata/influxdb-client-python/issues/59): Set User-Agent to influxdb-client-python/VERSION for all requests

### Bugs
### Bug Fixes
1. [#61](https://github.com/influxdata/influxdb-client-python/issues/61): Correctly parse CSV where multiple results include multiple tables
1. [#66](https://github.com/influxdata/influxdb-client-python/issues/66): Correctly close connection pool manager at exit
1. [#69](https://github.com/influxdata/influxdb-client-python/issues/69): `InfluxDBClient` and `WriteApi` could serialized by [pickle](https://docs.python.org/3/library/pickle.html#object.__getstate__) (python3.7 or higher)
Expand All @@ -24,7 +25,7 @@
### CI
1. [#54](https://github.com/influxdata/influxdb-client-python/pull/54): Add Python 3.7 and 3.8 to CI builds

### Bugs
### Bug Fixes
1. [#56](https://github.com/influxdata/influxdb-client-python/pull/56): Fix default tags for write batching, added new test
1. [#58](https://github.com/influxdata/influxdb-client-python/pull/58): Source distribution also contains: requirements.txt, extra-requirements.txt and test-requirements.txt

Expand All @@ -39,7 +40,7 @@
### CI
1. [#49](https://github.com/influxdata/influxdb-client-python/pull/49): Added beta release to continuous integration

### Bugs
### Bug Fixes
1. [#48](https://github.com/influxdata/influxdb-client-python/pull/48): InfluxDBClient default org is used by WriteAPI

## 1.2.0 [2019-12-06]
Expand All @@ -50,7 +51,7 @@
### API
1. [#42](https://github.com/influxdata/influxdb-client-python/pull/42): Updated swagger to latest version

### Bugs
### Bug Fixes
1. [#45](https://github.com/influxdata/influxdb-client-python/pull/45): Pandas is a optional dependency and has to installed separably

## 1.1.0 [2019-11-19]
Expand All @@ -70,7 +71,7 @@
### API
1. [#28](https://github.com/bonitoo-io/influxdb-client-python/pull/28): Updated swagger to latest version

### Bugs
### Bug Fixes
1. [#19](https://github.com/bonitoo-io/influxdb-client-python/pull/19): Removed strict checking of enum values

### Documentation
Expand All @@ -85,7 +86,7 @@
### API
1. [#10](https://github.com/bonitoo-io/influxdb-client-python/pull/10): Updated swagger to latest version

### Bugs
### Bug Fixes
1. [#3](https://github.com/bonitoo-io/influxdb-client-python/issues/3): The management API correctly supports inheritance defined in Influx API
1. [#7](https://github.com/bonitoo-io/influxdb-client-python/issues/7): Drop NaN and infinity values from fields when writing to InfluxDB

Expand Down
18 changes: 18 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ InfluxDB 2.0 client features
- authorizations
- health check
- ...
- `InfluxDB 1.8 API compatibility`_
- Examples
- `Connect to InfluxDB Cloud`_
- `How to efficiently import large dataset`_
Expand Down Expand Up @@ -859,6 +860,23 @@ Gzip support
.. marker-gzip-end
InfluxDB 1.8 API compatibility
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

`InfluxDB 1.8.0 introduced forward compatibility APIs <https://docs.influxdata.com/influxdb/latest/tools/api/#influxdb-2-0-api-compatibility-endpoints>`_ for InfluxDB 2.0. This allow you to easily move from InfluxDB 1.x to InfluxDB 2.0 Cloud or open source.

The following forward compatible APIs are available:

======================================================= ==================================================================================================== =======
API Endpoint Description
======================================================= ==================================================================================================== =======
`query_api.py <influxdb_client/client/query_api.py>`_ `/api/v2/query <https://docs.influxdata.com/influxdb/latest/tools/api/#api-v2-query-http-endpoint>`_ Query data in InfluxDB 1.8.0+ using the InfluxDB 2.0 API and `Flux <https://docs.influxdata.com/flux/latest/>`_ (endpoint should be enabled by `flux-enabled option <https://docs.influxdata.com/influxdb/latest/administration/config/#flux-enabled-false>`_)
`write_api.py <influxdb_client/client/write_api.py>`_ `/api/v2/write <https://docs.influxdata.com/influxdb/latest/tools/api/#api-v2-write-http-endpoint>`_ Write data to InfluxDB 1.8.0+ using the InfluxDB 2.0 API
`health() <influxdb_client/client/influxdb_client.py>`_ `/health <https://docs.influxdata.com/influxdb/latest/tools/api/#health-http-endpointt>`_ Check the health of your InfluxDB instance
======================================================= ==================================================================================================== =======

For detail info see `InfluxDB 1.8 example <examples/influxdb_18_example.py>`_.

Local tests
-----------

Expand Down
31 changes: 31 additions & 0 deletions examples/influxdb_18_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from influxdb_client import InfluxDBClient, Point

username = 'username'
password = 'password'

database = 'telegraf'
retention_policy = 'autogen'

bucket = f'{database}/{retention_policy}'

client = InfluxDBClient(url='http://localhost:8086', token=f'{username}:{password}', org='-')

print('*** Write Points ***')

write_api = client.write_api()

point = Point("mem").tag("host", "host1").field("used_percent", 25.43234543)
print(point.to_line_protocol())

write_api.write(bucket=bucket, record=point)
write_api.__del__()

print('*** Query Points ***')

query_api = client.query_api()
query = f'from(bucket: \"{bucket}\") |> range(start: -1h)'
tables = query_api.query(query)
for record in tables[0].records:
print(f'#{record.get_time()} #{record.get_measurement()}: #{record.get_field()} #{record.get_value()}')

client.close()

0 comments on commit d6ba893

Please sign in to comment.