diff --git a/.gitignore b/.gitignore
index d970c44c..2c1a9532 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,3 +22,7 @@ docs/build/
.coverage
cover
env
+.vscode
+venv
+scripts
+*.egg-info
diff --git a/.travis.yml b/.travis.yml
index 9d45f19b..d25d836b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,6 @@
language: python
python:
- - "2.7"
- - "3.5"
- "3.6"
- "3.7"
- "pypy"
diff --git a/README.md b/README.md
new file mode 100644
index 00000000..d29d0d2a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,75 @@
+## InfluxDB-Python-Aio
+--------------
+
+### Statement
+**This was forked from (https://github.com/influxdata/influxdb-python), and support asyncio.**
+[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.
+
+InfluxDB-Python is a client for interacting with InfluxDB_.
+
+Development of this library is maintained by:
+
+| Github ID| URL |
+| --- | --- |
+| @aviau | (https://github.com/aviau) |
+| @xginn8 | (https://github.com/xginn8) |
+| @sebito91 | (https://github.com/sebito91) |
+
+### Installation
+
+Install, upgrade and uninstall influxdb-aio with these commands::
+
+ $ pip install influxdb-aio
+ $ pip install --upgrade influxdb-aio
+ $ pip uninstall influxdb-aio
+
+### Dependencies
+
+The influxdb-python distribution is supported only on Python 3.6, 3.7, etc.
+
+
+Main dependency is:
+
+- httpx: A next generation HTTP client for Python. (https://github.com/encode/httpx)
+
+
+### Examples
+--------
+
+Here's a basic example (for more see the examples directory)
+
+```python
+import asyncio
+from influxdb_aio import InfluxDBClient
+
+
+json_body = [
+ {
+ "measurement": "cpu_load_short",
+ "tags": {
+ "host": "server01",
+ "region": "us-west"
+ },
+ "time": "2009-11-10T23:00:00Z",
+ "fields": {
+ "value": 0.64
+ }
+ }
+]
+
+
+async def init_client():
+ client = await InfluxDBClient('localhost', 8086, 'root', 'root', 'example')
+ await client.create_database('example')
+ return client.write_points(json_body)
+
+
+async def main():
+ client = await init_client()
+ result = await client.query('select value from cpu_load_short;')
+ print("Result: {0}".format(result))
+
+
+if __name__ == '__main__' :
+ asyncio.get_event_loop().run_until_complete(main())
+```
diff --git a/README.rst b/README.original.rst
similarity index 98%
rename from README.rst
rename to README.original.rst
index a40ed148..1f70b01f 100644
--- a/README.rst
+++ b/README.original.rst
@@ -12,7 +12,7 @@ InfluxDB-Python
:alt: Coverage
.. image:: https://img.shields.io/pypi/v/influxdb.svg
- :target: https://pypi.python.org/pypi/influxdb
+ :target: https://pypi.org/project/influxdb-aio/
:alt: PyPI Status
InfluxDB-Python is a client for interacting with InfluxDB_.
diff --git a/dev-requirements.txt b/dev-requirements.txt
index bc7b4c87..b7e84c78 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -1,4 +1,4 @@
-requests>=2.17.0
+httpx>=0.13.3
nose
mock
pandas==0.20.1
@@ -6,3 +6,4 @@ Sphinx==1.5.5
sphinx_rtd_theme
wheel
twine
+tox
diff --git a/influxdb/__init__.py b/influxdb_aio/__init__.py
similarity index 94%
rename from influxdb/__init__.py
rename to influxdb_aio/__init__.py
index 56f2f619..e66f80ea 100644
--- a/influxdb/__init__.py
+++ b/influxdb_aio/__init__.py
@@ -18,4 +18,4 @@
]
-__version__ = '5.3.0'
+__version__ = '5.3.2'
diff --git a/influxdb/_dataframe_client.py b/influxdb_aio/_dataframe_client.py
similarity index 100%
rename from influxdb/_dataframe_client.py
rename to influxdb_aio/_dataframe_client.py
diff --git a/influxdb/chunked_json.py b/influxdb_aio/chunked_json.py
similarity index 100%
rename from influxdb/chunked_json.py
rename to influxdb_aio/chunked_json.py
diff --git a/influxdb/client.py b/influxdb_aio/client.py
similarity index 90%
rename from influxdb/client.py
rename to influxdb_aio/client.py
index df9ef966..e759990c 100644
--- a/influxdb/client.py
+++ b/influxdb_aio/client.py
@@ -1,15 +1,14 @@
# -*- coding: utf-8 -*-
"""Python client for InfluxDB."""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
+from __future__ import (absolute_import, division, print_function,
+ unicode_literals)
+import asyncio
import datetime
import gzip
-import itertools
import io
+import itertools
import json
import random
import socket
@@ -17,15 +16,14 @@
import time
from itertools import chain, islice
+import httpx
import msgpack
-import requests
-import requests.exceptions
from six.moves.urllib.parse import urlparse
-from influxdb.line_protocol import make_lines, quote_ident, quote_literal
-from influxdb.resultset import ResultSet
-from .exceptions import InfluxDBClientError
-from .exceptions import InfluxDBServerError
+from influxdb_aio.line_protocol import make_lines, quote_ident, quote_literal
+from influxdb_aio.resultset import ResultSet
+
+from .exceptions import InfluxDBClientError, InfluxDBServerError
class InfluxDBClient(object):
@@ -124,15 +122,6 @@ def __init__(self,
self.__use_udp = use_udp
self.__udp_port = int(udp_port)
- if not session:
- session = requests.Session()
-
- self._session = session
- adapter = requests.adapters.HTTPAdapter(
- pool_connections=int(pool_size),
- pool_maxsize=int(pool_size)
- )
-
if use_udp:
self.udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@@ -148,13 +137,29 @@ def __init__(self,
if ssl is True:
self._scheme = "https"
- self._session.mount(self._scheme + '://', adapter)
-
if proxies is None:
self._proxies = {}
else:
self._proxies = proxies
+ if not session:
+ pool_limit = httpx.PoolLimits(max_connections=int(pool_size))
+ # session = requests.Session()
+ session = httpx.AsyncClient(
+ pool_limits=pool_limit,
+ proxies=self._proxies,
+ verify=self._verify_ssl,
+ trust_env=False
+ )
+
+ self._session = session
+ # adapter = requests.adapters.HTTPAdapter(
+ # pool_connections=int(pool_size),
+ # pool_maxsize=int(pool_size)
+ # )
+
+ # self._session.mount(self._scheme + '://', adapter)
+
if cert:
if not ssl:
raise ValueError(
@@ -269,7 +274,7 @@ def switch_user(self, username, password):
self._username = username
self._password = password
- def request(self, url, method='GET', params=None, data=None, stream=False,
+ async def request(self, url, method='GET', params=None, data=None, stream=False,
expected_response_code=200, headers=None):
"""Make a HTTP request to the InfluxDB API.
@@ -328,22 +333,22 @@ def request(self, url, method='GET', params=None, data=None, stream=False,
_try = 0
while retry:
try:
- response = self._session.request(
+ response = await self._session.request(
method=method,
url=url,
auth=(self._username, self._password),
params=params,
data=data,
- stream=stream,
+ # stream=stream,
headers=headers,
- proxies=self._proxies,
- verify=self._verify_ssl,
timeout=self._timeout
)
break
- except (requests.exceptions.ConnectionError,
- requests.exceptions.HTTPError,
- requests.exceptions.Timeout):
+ except (httpx.ConnectError,
+ httpx.HTTPError,
+ httpx.ConnectTimeout,
+ httpx.ReadTimeout,
+ httpx.WriteTimeout):
_try += 1
if self._retries != 0:
retry = _try < self._retries
@@ -376,7 +381,7 @@ def reformat_error(response):
err_msg = reformat_error(response)
raise InfluxDBClientError(err_msg, response.status_code)
- def write(self, data, params=None, expected_response_code=204,
+ async def write(self, data, params=None, expected_response_code=204,
protocol='json'):
"""Write data to InfluxDB.
@@ -409,7 +414,7 @@ def write(self, data, params=None, expected_response_code=204,
data = [data]
data = ('\n'.join(data) + '\n').encode('utf-8')
- self.request(
+ await self.request(
url="write",
method='POST',
params=params,
@@ -433,7 +438,7 @@ def _read_chunked_response(response, raise_errors=True):
_key, []).extend(result[_key])
yield ResultSet(result_set, raise_errors=raise_errors)
- def query(self,
+ async def query(self,
query,
params=None,
bind_params=None,
@@ -517,7 +522,7 @@ def query(self,
if query.lower().startswith("select ") and " into " in query.lower():
method = "POST"
- response = self.request(
+ response = await self.request(
url="query",
method=method,
params=params,
@@ -544,7 +549,7 @@ def query(self,
return results
- def write_points(self,
+ async def write_points(self,
points,
time_precision=None,
database=None,
@@ -591,7 +596,7 @@ def write_points(self,
"""
if batch_size and batch_size > 0:
for batch in self._batches(points, batch_size):
- self._write_points(points=batch,
+ await self._write_points(points=batch,
time_precision=time_precision,
database=database,
retention_policy=retention_policy,
@@ -599,19 +604,19 @@ def write_points(self,
consistency=consistency)
return True
- return self._write_points(points=points,
+ return await self._write_points(points=points,
time_precision=time_precision,
database=database,
retention_policy=retention_policy,
tags=tags, protocol=protocol,
consistency=consistency)
- def ping(self):
+ async def ping(self):
"""Check connectivity to InfluxDB.
:returns: The version of the InfluxDB the client is connected to
"""
- response = self.request(
+ response = await self.request(
url="ping",
method='GET',
expected_response_code=204
@@ -633,7 +638,7 @@ def _batches(iterable, size):
rest = islice(iterator, size - 1)
yield chain(head, rest)
- def _write_points(self,
+ async def _write_points(self,
points,
time_precision,
database,
@@ -677,7 +682,7 @@ def _write_points(self,
data, protocol=protocol, time_precision=time_precision
)
else:
- self.write(
+ await self.write(
data=data,
params=params,
expected_response_code=204,
@@ -702,7 +707,7 @@ def get_list_database(self):
"""
return list(self.query("SHOW DATABASES").get_points())
- def get_list_series(self, database=None, measurement=None, tags=None):
+ async def get_list_series(self, database=None, measurement=None, tags=None):
"""
Query SHOW SERIES returns the distinct series in your database.
@@ -730,31 +735,31 @@ def get_list_series(self, database=None, measurement=None, tags=None):
itertools.chain.from_iterable(
[
x.values()
- for x in (self.query(query_str, database=database)
+ for x in (await self.query(query_str, database=database)
.get_points())
]
)
)
- def create_database(self, dbname):
+ async def create_database(self, dbname):
"""Create a new database in InfluxDB.
:param dbname: the name of the database to create
:type dbname: str
"""
- self.query("CREATE DATABASE {0}".format(quote_ident(dbname)),
+ await self.query("CREATE DATABASE {0}".format(quote_ident(dbname)),
method="POST")
- def drop_database(self, dbname):
+ async def drop_database(self, dbname):
"""Drop a database from InfluxDB.
:param dbname: the name of the database to drop
:type dbname: str
"""
- self.query("DROP DATABASE {0}".format(quote_ident(dbname)),
+ await self.query("DROP DATABASE {0}".format(quote_ident(dbname)),
method="POST")
- def get_list_measurements(self):
+ async def get_list_measurements(self):
"""Get the list of measurements in InfluxDB.
:returns: all measurements in InfluxDB
@@ -770,18 +775,18 @@ def get_list_measurements(self):
{u'name': u'measurements2'},
{u'name': u'measurements3'}]
"""
- return list(self.query("SHOW MEASUREMENTS").get_points())
+ return list(await self.query("SHOW MEASUREMENTS").get_points())
- def drop_measurement(self, measurement):
+ async def drop_measurement(self, measurement):
"""Drop a measurement from InfluxDB.
:param measurement: the name of the measurement to drop
:type measurement: str
"""
- self.query("DROP MEASUREMENT {0}".format(quote_ident(measurement)),
+ await self.query("DROP MEASUREMENT {0}".format(quote_ident(measurement)),
method="POST")
- def create_retention_policy(self, name, duration, replication,
+ async def create_retention_policy(self, name, duration, replication,
database=None,
default=False, shard_duration="0s"):
"""Create a retention policy for a database.
@@ -821,9 +826,9 @@ def create_retention_policy(self, name, duration, replication,
if default is True:
query_string += " DEFAULT"
- self.query(query_string, method="POST")
+ await self.query(query_string, method="POST")
- def alter_retention_policy(self, name, database=None,
+ async def alter_retention_policy(self, name, database=None,
duration=None, replication=None,
default=None, shard_duration=None):
"""Modify an existing retention policy for a database.
@@ -870,9 +875,9 @@ def alter_retention_policy(self, name, database=None,
if default is True:
query_string += " DEFAULT"
- self.query(query_string, method="POST")
+ await self.query(query_string, method="POST")
- def drop_retention_policy(self, name, database=None):
+ async def drop_retention_policy(self, name, database=None):
"""Drop an existing retention policy for a database.
:param name: the name of the retention policy to drop
@@ -884,9 +889,9 @@ def drop_retention_policy(self, name, database=None):
query_string = (
"DROP RETENTION POLICY {0} ON {1}"
).format(quote_ident(name), quote_ident(database or self._database))
- self.query(query_string, method="POST")
+ await self.query(query_string, method="POST")
- def get_list_retention_policies(self, database=None):
+ async def get_list_retention_policies(self, database=None):
"""Get the list of retention policies for a database.
:param database: the name of the database, defaults to the client's
@@ -911,13 +916,13 @@ def get_list_retention_policies(self, database=None):
"get_list_retention_policies() requires a database as a "
"parameter or the client to be using a database")
- rsp = self.query(
+ rsp = await self.query(
"SHOW RETENTION POLICIES ON {0}".format(
quote_ident(database or self._database))
)
return list(rsp.get_points())
- def get_list_users(self):
+ async def get_list_users(self):
"""Get the list of all users in InfluxDB.
:returns: all users in InfluxDB
@@ -933,9 +938,9 @@ def get_list_users(self):
{u'admin': False, u'user': u'user2'},
{u'admin': False, u'user': u'user3'}]
"""
- return list(self.query("SHOW USERS").get_points())
+ return list(await self.query("SHOW USERS").get_points())
- def create_user(self, username, password, admin=False):
+ async def create_user(self, username, password, admin=False):
"""Create a new user in InfluxDB.
:param username: the new username to create
@@ -950,18 +955,18 @@ def create_user(self, username, password, admin=False):
quote_ident(username), quote_literal(password))
if admin:
text += ' WITH ALL PRIVILEGES'
- self.query(text, method="POST")
+ await self.query(text, method="POST")
- def drop_user(self, username):
+ async def drop_user(self, username):
"""Drop a user from InfluxDB.
:param username: the username to drop
:type username: str
"""
text = "DROP USER {0}".format(quote_ident(username))
- self.query(text, method="POST")
+ await self.query(text, method="POST")
- def set_user_password(self, username, password):
+ async def set_user_password(self, username, password):
"""Change the password of an existing user.
:param username: the username who's password is being changed
@@ -971,9 +976,9 @@ def set_user_password(self, username, password):
"""
text = "SET PASSWORD FOR {0} = {1}".format(
quote_ident(username), quote_literal(password))
- self.query(text)
+ await self.query(text)
- def delete_series(self, database=None, measurement=None, tags=None):
+ async def delete_series(self, database=None, measurement=None, tags=None):
"""Delete series from a database.
Series must be filtered by either measurement and tags.
@@ -997,9 +1002,9 @@ def delete_series(self, database=None, measurement=None, tags=None):
tag_eq_list = ["{0}={1}".format(quote_ident(k), quote_literal(v))
for k, v in tags.items()]
query_str += ' WHERE ' + ' AND '.join(tag_eq_list)
- self.query(query_str, database=database, method="POST")
+ await self.query(query_str, database=database, method="POST")
- def grant_admin_privileges(self, username):
+ async def grant_admin_privileges(self, username):
"""Grant cluster administration privileges to a user.
:param username: the username to grant privileges to
@@ -1009,9 +1014,9 @@ def grant_admin_privileges(self, username):
and manage users.
"""
text = "GRANT ALL PRIVILEGES TO {0}".format(quote_ident(username))
- self.query(text, method="POST")
+ await self.query(text, method="POST")
- def revoke_admin_privileges(self, username):
+ async def revoke_admin_privileges(self, username):
"""Revoke cluster administration privileges from a user.
:param username: the username to revoke privileges from
@@ -1021,9 +1026,9 @@ def revoke_admin_privileges(self, username):
and manage users.
"""
text = "REVOKE ALL PRIVILEGES FROM {0}".format(quote_ident(username))
- self.query(text, method="POST")
+ await self.query(text, method="POST")
- def grant_privilege(self, privilege, database, username):
+ async def grant_privilege(self, privilege, database, username):
"""Grant a privilege on a database to a user.
:param privilege: the privilege to grant, one of 'read', 'write'
@@ -1037,9 +1042,9 @@ def grant_privilege(self, privilege, database, username):
text = "GRANT {0} ON {1} TO {2}".format(privilege,
quote_ident(database),
quote_ident(username))
- self.query(text, method="POST")
+ await self.query(text, method="POST")
- def revoke_privilege(self, privilege, database, username):
+ async def revoke_privilege(self, privilege, database, username):
"""Revoke a privilege on a database from a user.
:param privilege: the privilege to revoke, one of 'read', 'write'
@@ -1053,9 +1058,9 @@ def revoke_privilege(self, privilege, database, username):
text = "REVOKE {0} ON {1} FROM {2}".format(privilege,
quote_ident(database),
quote_ident(username))
- self.query(text, method="POST")
+ await self.query(text, method="POST")
- def get_list_privileges(self, username):
+ async def get_list_privileges(self, username):
"""Get the list of all privileges granted to given user.
:param username: the username to get privileges of
@@ -1075,9 +1080,9 @@ def get_list_privileges(self, username):
{u'privilege': u'NO PRIVILEGES', u'database': u'db3'}]
"""
text = "SHOW GRANTS FOR {0}".format(quote_ident(username))
- return list(self.query(text).get_points())
+ return list(await self.query(text).get_points())
- def get_list_continuous_queries(self):
+ async def get_list_continuous_queries(self):
"""Get the list of continuous queries in InfluxDB.
:return: all CQs in InfluxDB
@@ -1107,9 +1112,9 @@ def get_list_continuous_queries(self):
]
"""
query_string = "SHOW CONTINUOUS QUERIES"
- return [{sk[0]: list(p)} for sk, p in self.query(query_string).items()]
+ return [{sk[0]: list(p)} for sk, p in await self.query(query_string).items()]
- def create_continuous_query(self, name, select, database=None,
+ async def create_continuous_query(self, name, select, database=None,
resample_opts=None):
r"""Create a continuous query for a database.
@@ -1153,9 +1158,9 @@ def create_continuous_query(self, name, select, database=None,
"CREATE CONTINUOUS QUERY {0} ON {1}{2} BEGIN {3} END"
).format(quote_ident(name), quote_ident(database or self._database),
' RESAMPLE ' + resample_opts if resample_opts else '', select)
- self.query(query_string)
+ await self.query(query_string)
- def drop_continuous_query(self, name, database=None):
+ async def drop_continuous_query(self, name, database=None):
"""Drop an existing continuous query for a database.
:param name: the name of continuous query to drop
@@ -1167,7 +1172,7 @@ def drop_continuous_query(self, name, database=None):
query_string = (
"DROP CONTINUOUS QUERY {0} ON {1}"
).format(quote_ident(name), quote_ident(database or self._database))
- self.query(query_string)
+ await self.query(query_string)
def send_packet(self, packet, protocol='json', time_precision=None):
"""Send an UDP packet.
@@ -1186,10 +1191,10 @@ def send_packet(self, packet, protocol='json', time_precision=None):
data = ('\n'.join(packet) + '\n').encode('utf-8')
self.udp_socket.sendto(data, (self._host, self._udp_port))
- def close(self):
+ async def close(self):
"""Close http session."""
- if isinstance(self._session, requests.Session):
- self._session.close()
+ if isinstance(self._session, httpx.AsyncClient):
+ await self._session.aclose()
def _parse_dsn(dsn):
diff --git a/influxdb/dataframe_client.py b/influxdb_aio/dataframe_client.py
similarity index 100%
rename from influxdb/dataframe_client.py
rename to influxdb_aio/dataframe_client.py
diff --git a/influxdb/exceptions.py b/influxdb_aio/exceptions.py
similarity index 100%
rename from influxdb/exceptions.py
rename to influxdb_aio/exceptions.py
diff --git a/influxdb/helper.py b/influxdb_aio/helper.py
similarity index 100%
rename from influxdb/helper.py
rename to influxdb_aio/helper.py
diff --git a/influxdb/influxdb08/__init__.py b/influxdb_aio/influxdb08/__init__.py
similarity index 100%
rename from influxdb/influxdb08/__init__.py
rename to influxdb_aio/influxdb08/__init__.py
diff --git a/influxdb/influxdb08/chunked_json.py b/influxdb_aio/influxdb08/chunked_json.py
similarity index 100%
rename from influxdb/influxdb08/chunked_json.py
rename to influxdb_aio/influxdb08/chunked_json.py
diff --git a/influxdb/influxdb08/client.py b/influxdb_aio/influxdb08/client.py
similarity index 100%
rename from influxdb/influxdb08/client.py
rename to influxdb_aio/influxdb08/client.py
diff --git a/influxdb/influxdb08/dataframe_client.py b/influxdb_aio/influxdb08/dataframe_client.py
similarity index 100%
rename from influxdb/influxdb08/dataframe_client.py
rename to influxdb_aio/influxdb08/dataframe_client.py
diff --git a/influxdb/influxdb08/helper.py b/influxdb_aio/influxdb08/helper.py
similarity index 100%
rename from influxdb/influxdb08/helper.py
rename to influxdb_aio/influxdb08/helper.py
diff --git a/influxdb/line_protocol.py b/influxdb_aio/line_protocol.py
similarity index 100%
rename from influxdb/line_protocol.py
rename to influxdb_aio/line_protocol.py
diff --git a/influxdb/resultset.py b/influxdb_aio/resultset.py
similarity index 99%
rename from influxdb/resultset.py
rename to influxdb_aio/resultset.py
index ba4f3c13..19de1d20 100644
--- a/influxdb/resultset.py
+++ b/influxdb_aio/resultset.py
@@ -8,7 +8,7 @@
import warnings
-from influxdb.exceptions import InfluxDBClientError
+from influxdb_aio.exceptions import InfluxDBClientError
_sentinel = object()
diff --git a/influxdb/tests/__init__.py b/influxdb_aio/tests/__init__.py
similarity index 100%
rename from influxdb/tests/__init__.py
rename to influxdb_aio/tests/__init__.py
diff --git a/influxdb/tests/chunked_json_test.py b/influxdb_aio/tests/chunked_json_test.py
similarity index 100%
rename from influxdb/tests/chunked_json_test.py
rename to influxdb_aio/tests/chunked_json_test.py
diff --git a/influxdb/tests/client_test.py b/influxdb_aio/tests/client_test.py
similarity index 99%
rename from influxdb/tests/client_test.py
rename to influxdb_aio/tests/client_test.py
index fd3c06bb..074a66f0 100644
--- a/influxdb/tests/client_test.py
+++ b/influxdb_aio/tests/client_test.py
@@ -14,32 +14,33 @@
"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
+from __future__ import (absolute_import, division, print_function,
+ unicode_literals)
+import gzip
+import io
+import json
import random
import socket
import unittest
import warnings
-import io
-import gzip
-import json
+import httpx
import mock
-import requests
-import requests.exceptions
-import requests_mock
-
+import respx
from nose.tools import raises
from influxdb import InfluxDBClient
from influxdb.resultset import ResultSet
+# import requests
+# import requests.exceptions
+# import requests_mock
+
def _build_response_object(status_code=200, content=""):
- resp = requests.Response()
+ # resp = requests.Response()
+ resp = httpx.Response()
resp.status_code = status_code
resp._content = content.encode("utf8")
return resp
@@ -48,7 +49,7 @@ def _build_response_object(status_code=200, content=""):
def _mocked_session(cli, method="GET", status_code=200, content=""):
method = method.upper()
- def request(*args, **kwargs):
+ async def request(*args, **kwargs):
"""Request content from the mocked session."""
c = content
@@ -172,16 +173,16 @@ def test_switch_user(self):
self.assertEqual('another_username', cli._username)
self.assertEqual('another_password', cli._password)
- def test_write(self):
+ async def test_write(self):
"""Test write in TestInfluxDBClient object."""
- with requests_mock.Mocker() as m:
+ async with requests_mock.Mocker() as m:
m.register_uri(
requests_mock.POST,
"http://localhost:8086/write",
status_code=204
)
cli = InfluxDBClient(database='db')
- cli.write(
+ await cli.write(
{"database": "mydb",
"retentionPolicy": "mypolicy",
"points": [{"measurement": "cpu_load_short",
diff --git a/influxdb/tests/dataframe_client_test.py b/influxdb_aio/tests/dataframe_client_test.py
similarity index 100%
rename from influxdb/tests/dataframe_client_test.py
rename to influxdb_aio/tests/dataframe_client_test.py
diff --git a/influxdb/tests/helper_test.py b/influxdb_aio/tests/helper_test.py
similarity index 100%
rename from influxdb/tests/helper_test.py
rename to influxdb_aio/tests/helper_test.py
diff --git a/influxdb/tests/influxdb08/__init__.py b/influxdb_aio/tests/influxdb08/__init__.py
similarity index 100%
rename from influxdb/tests/influxdb08/__init__.py
rename to influxdb_aio/tests/influxdb08/__init__.py
diff --git a/influxdb/tests/influxdb08/client_test.py b/influxdb_aio/tests/influxdb08/client_test.py
similarity index 100%
rename from influxdb/tests/influxdb08/client_test.py
rename to influxdb_aio/tests/influxdb08/client_test.py
diff --git a/influxdb/tests/influxdb08/dataframe_client_test.py b/influxdb_aio/tests/influxdb08/dataframe_client_test.py
similarity index 100%
rename from influxdb/tests/influxdb08/dataframe_client_test.py
rename to influxdb_aio/tests/influxdb08/dataframe_client_test.py
diff --git a/influxdb/tests/influxdb08/helper_test.py b/influxdb_aio/tests/influxdb08/helper_test.py
similarity index 100%
rename from influxdb/tests/influxdb08/helper_test.py
rename to influxdb_aio/tests/influxdb08/helper_test.py
diff --git a/influxdb/tests/misc.py b/influxdb_aio/tests/misc.py
similarity index 100%
rename from influxdb/tests/misc.py
rename to influxdb_aio/tests/misc.py
diff --git a/influxdb/tests/resultset_test.py b/influxdb_aio/tests/resultset_test.py
similarity index 100%
rename from influxdb/tests/resultset_test.py
rename to influxdb_aio/tests/resultset_test.py
diff --git a/influxdb/tests/server_tests/__init__.py b/influxdb_aio/tests/server_tests/__init__.py
similarity index 100%
rename from influxdb/tests/server_tests/__init__.py
rename to influxdb_aio/tests/server_tests/__init__.py
diff --git a/influxdb/tests/server_tests/base.py b/influxdb_aio/tests/server_tests/base.py
similarity index 100%
rename from influxdb/tests/server_tests/base.py
rename to influxdb_aio/tests/server_tests/base.py
diff --git a/influxdb/tests/server_tests/client_test_with_server.py b/influxdb_aio/tests/server_tests/client_test_with_server.py
similarity index 100%
rename from influxdb/tests/server_tests/client_test_with_server.py
rename to influxdb_aio/tests/server_tests/client_test_with_server.py
diff --git a/influxdb/tests/server_tests/influxdb.conf.template b/influxdb_aio/tests/server_tests/influxdb.conf.template
similarity index 100%
rename from influxdb/tests/server_tests/influxdb.conf.template
rename to influxdb_aio/tests/server_tests/influxdb.conf.template
diff --git a/influxdb/tests/server_tests/influxdb_instance.py b/influxdb_aio/tests/server_tests/influxdb_instance.py
similarity index 100%
rename from influxdb/tests/server_tests/influxdb_instance.py
rename to influxdb_aio/tests/server_tests/influxdb_instance.py
diff --git a/influxdb/tests/test_line_protocol.py b/influxdb_aio/tests/test_line_protocol.py
similarity index 100%
rename from influxdb/tests/test_line_protocol.py
rename to influxdb_aio/tests/test_line_protocol.py
diff --git a/requirements.txt b/requirements.txt
index 548b17c8..8f5977fa 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,3 +3,4 @@ pytz
requests>=2.17.0
six>=1.10.0
msgpack
+httpx>=0.13.3
diff --git a/setup.py b/setup.py
index d44875f6..f2e7f97d 100755
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@
import re
-with open(os.path.join(os.path.dirname(__file__), 'influxdb', '__init__.py')) as f:
+with open(os.path.join(os.path.dirname(__file__), 'influxdb_aio', '__init__.py')) as f:
version = re.search("__version__ = '([^']+)'", f.read()).group(1)
with open('requirements.txt', 'r') as f:
@@ -31,27 +31,26 @@
setup(
- name='influxdb',
+ name='influxdb-aio',
version=version,
- description="InfluxDB client",
+ description="InfluxDB client, asyncio version",
long_description=readme,
- url='https://github.com/influxdb/influxdb-python',
+ url='https://github.com/xp880906/influxdb-python',
+ author='BruceX',
+ author_email='xp880906@gmail.com',
license='MIT License',
packages=find_packages(exclude=['tests']),
test_suite='tests',
tests_require=test_requires,
install_requires=requires,
extras_require={'test': test_requires},
+ python_requires='>=3.6',
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
- 'Programming Language :: Python :: 2.7',
- 'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.4',
- 'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules',
diff --git a/test-requirements.txt b/test-requirements.txt
index 9b31f5f1..545c0c72 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -2,3 +2,5 @@ nose
nose-cov
mock
requests-mock
+respx
+tox
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: