|
1 | 1 | ## InfluxDB-Python-Aio
|
2 | 2 | --------------
|
3 | 3 |
|
4 |
| -.. image:: https://travis-ci.org/influxdata/influxdb-python.svg?branch=master |
5 |
| - :target: https://travis-ci.org/influxdata/influxdb-python |
6 |
| -.. image:: https://readthedocs.org/projects/influxdb-python/badge/?version=latest&style |
7 |
| - :target: http://influxdb-python.readthedocs.org/ |
8 |
| - :alt: Documentation Status |
9 |
| - |
10 |
| -.. image:: https://img.shields.io/coveralls/influxdata/influxdb-python.svg |
11 |
| - :target: https://coveralls.io/r/influxdata/influxdb-python |
12 |
| - :alt: Coverage |
13 |
| - |
14 |
| -.. image:: https://img.shields.io/pypi/v/influxdb.svg |
15 |
| - :target: https://pypi.org/project/influxdb-aio/ |
16 |
| - :alt: PyPI Status |
17 |
| - |
18 |
| --------------- |
19 |
| - |
20 | 4 | ### Statement
|
21 | 5 | **This was forked from (https://github.com/influxdata/influxdb-python), and support asyncio.**<br/>
|
22 | 6 | [Here](README.original.rst) is the original README document. You can find more detail about InfluxDB-Python (client) and also influxdb (database). Here is only some difference and basic usage.
|
@@ -54,36 +38,38 @@ Main dependency is:
|
54 | 38 |
|
55 | 39 | Here's a basic example (for more see the examples directory)
|
56 | 40 |
|
57 |
| - ~~~python |
58 |
| - import asyncio |
59 |
| - from influxdb_aio import InfluxDBClient |
60 |
| - |
61 |
| - json_body = [ |
62 |
| - { |
63 |
| - "measurement": "cpu_load_short", |
64 |
| - "tags": { |
65 |
| - "host": "server01", |
66 |
| - "region": "us-west" |
67 |
| - }, |
68 |
| - "time": "2009-11-10T23:00:00Z", |
69 |
| - "fields": { |
70 |
| - "value": 0.64 |
71 |
| - } |
| 41 | +```python |
| 42 | +import asyncio |
| 43 | +from influxdb_aio import InfluxDBClient |
| 44 | + |
| 45 | + |
| 46 | +json_body = [ |
| 47 | + { |
| 48 | + "measurement": "cpu_load_short", |
| 49 | + "tags": { |
| 50 | + "host": "server01", |
| 51 | + "region": "us-west" |
| 52 | + }, |
| 53 | + "time": "2009-11-10T23:00:00Z", |
| 54 | + "fields": { |
| 55 | + "value": 0.64 |
72 | 56 | }
|
73 |
| - ] |
| 57 | + } |
| 58 | +] |
| 59 | + |
74 | 60 |
|
75 |
| - async def init_client(): |
76 |
| - client = await InfluxDBClient('localhost', 8086, 'root', 'root', 'example') |
77 |
| - await client.create_database('example') |
78 |
| - return client.write_points(json_body) |
| 61 | +async def init_client(): |
| 62 | + client = await InfluxDBClient('localhost', 8086, 'root', 'root', 'example') |
| 63 | + await client.create_database('example') |
| 64 | + return client.write_points(json_body) |
79 | 65 |
|
80 | 66 |
|
81 |
| - async def main(): |
82 |
| - client = await init_client() |
83 |
| - result = await client.query('select value from cpu_load_short;') |
84 |
| - print("Result: {0}".format(result)) |
| 67 | +async def main(): |
| 68 | + client = await init_client() |
| 69 | + result = await client.query('select value from cpu_load_short;') |
| 70 | + print("Result: {0}".format(result)) |
85 | 71 |
|
86 | 72 |
|
87 |
| - if __name__ == '__main__' : |
88 |
| - asyncio.get_event_loop().run_until_complete(main()) |
89 |
| - ~~~ |
| 73 | +if __name__ == '__main__' : |
| 74 | + asyncio.get_event_loop().run_until_complete(main()) |
| 75 | +``` |
0 commit comments