Giter Site home page Giter Site logo

influxdb-python's Introduction

The v1 client libraries for InfluxDB were typically developed and maintained by community members. For InfluxDB 3.0 users, this library is succeeded by the lightweight v3 client library. For InfluxDB 2.0 users, look at the v2 client library.

If there are still users of this v1 client library, and they or somebody else are willing to keep them updated with security fixes at a minimum please reach out on the Community Forums or InfluxData Slack.

InfluxDB-Python

https://travis-ci.org/influxdata/influxdb-python.svg?branch=master Documentation Status Coverage PyPI Status

InfluxDB-Python is a client for interacting with InfluxDB.

Note: This library is for use with InfluxDB 1.x. For connecting to InfluxDB 2.x instances, please use the the influxdb-client-python client.

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)

InfluxDB is an open-source distributed time series database, find more about InfluxDB at https://docs.influxdata.com/influxdb/latest

InfluxDB pre v1.1.0 users

This module is tested with InfluxDB versions: v1.2.4, v1.3.9, v1.4.3, v1.5.4, v1.6.4, and 1.7.4.

Those users still on InfluxDB v0.8.x users may still use the legacy client by importing from influxdb.influxdb08 import InfluxDBClient.

Installation

Install, upgrade and uninstall influxdb-python with these commands:

$ pip install influxdb
$ pip install --upgrade influxdb
$ pip uninstall influxdb

On Debian/Ubuntu, you can install it with this command:

$ sudo apt-get install python-influxdb

Dependencies

The influxdb-python distribution is supported and tested on Python 2.7, 3.5, 3.6, 3.7, PyPy and PyPy3.

Note: Python <3.5 are currently untested. See .travis.yml.

Main dependency is:

Additional dependencies are:

Documentation

Documentation is available at https://influxdb-python.readthedocs.io/en/latest/.

You will need Sphinx installed to generate the documentation.

The documentation can be generated by running:

$ tox -e docs

Generated documentation can be found in the docs/build/html/ directory.

Examples

Here's a basic example (for more see the examples directory):

$ python

>>> from influxdb import InfluxDBClient

>>> json_body = [
    {
        "measurement": "cpu_load_short",
        "tags": {
            "host": "server01",
            "region": "us-west"
        },
        "time": "2009-11-10T23:00:00Z",
        "fields": {
            "value": 0.64
        }
    }
]

>>> client = InfluxDBClient('localhost', 8086, 'root', 'root', 'example')

>>> client.create_database('example')

>>> client.write_points(json_body)

>>> result = client.query('select value from cpu_load_short;')

>>> print("Result: {0}".format(result))

Testing

Make sure you have tox by running the following:

$ pip install tox

To test influxdb-python with multiple version of Python, you can use Tox:

$ tox

Support

For issues with, questions about, or feedback for InfluxDB, please look into our community page: http://influxdb.com/community/.

We are also lurking on the following:

  • #influxdb on irc.freenode.net
  • #influxdb on gophers.slack.com

Development

All development is done on Github. Use Issues to report problems or submit contributions.

Please note that we WILL get to your questions/issues/concerns as quickly as possible. We maintain many software repositories and sometimes things may get pushed to the backburner. Please don't take offense, we will do our best to reply as soon as possible!

Source code

The source code is currently available on Github: https://github.com/influxdata/influxdb-python

TODO

The TODO/Roadmap can be found in Github bug tracker: https://github.com/influxdata/influxdb-python/issues

influxdb-python's People

Contributors

acobaugh avatar areski avatar aviau avatar bbinet avatar cadnce avatar cannium avatar clslgrnc avatar djeebus avatar gaker avatar geodimm avatar gusutabopb avatar h0bot avatar jonashaag avatar jvshahid avatar kipe avatar lra avatar pierref avatar powersj avatar prune998 avatar rhajek avatar rolincova avatar sebito91 avatar timtroendle avatar toddboom avatar trehn avatar tzonghao avatar voidfiles avatar william-p avatar wwentland avatar xginn8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

influxdb-python's Issues

tutorial_sine_wave.py fails

System config:

  • Ubuntu 14.04 x86_64
  • Python 3.4
  • InfluxDB 0.9.0-rc18
  • influxdb-python 1.0.2

Attempting to run the tutorial_sine_wave.py programme produces this output:

python3 tutorial_sine_wave.py 
Create database: tutorial
Traceback (most recent call last):
  File "tutorial_sine_wave.py", line 66, in <module>
    main(host=args.host, port=args.port)
  File "tutorial_sine_wave.py", line 35, in main
    client.write_points(data)
  File "/usr/local/lib/python3.4/dist-packages/influxdb/client.py", line 255, in write_points
    retention_policy=retention_policy)
  File "/usr/local/lib/python3.4/dist-packages/influxdb/client.py", line 289, in _write_points
    expected_response_code=200
  File "/usr/local/lib/python3.4/dist-packages/influxdb/client.py", line 200, in write
    expected_response_code=expected_response_code
  File "/usr/local/lib/python3.4/dist-packages/influxdb/client.py", line 191, in request
    raise InfluxDBClientError(response.content, response.status_code)
influxdb.client.InfluxDBClientError: 500: {"error":"fields required"}

Is there currently a working way to write multiple samples (using the 'columns' and 'points' keys) or are we stuck writing single points, using 'fields' and 'timestamp'?

Improve build times

Build times have gotten longer with panda: From an average of 6 mins to 1 hour.

(They don't really take 1 hour because travis runs many jobs at a time)

Would there be a clever way to speed them up? I would not want to reduce testing just for the sake of faster builds tho.

add user to db...Exception: 400..

db.add_database_user("sirvon", "pass")
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/influxdb/client.py", line 476, in add_database_user
"{0}: {1}".format(response.status_code, response.content))
Exception: 400: Username cannot be empty

db.add_database_user("sirvon", "pass")
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/influxdb/client.py", line 476, in add_database_user
"{0}: {1}".format(response.status_code, response.content))
Exception: 400: Username cannot be empty

Maybe this error is due to this change: #7

plan to support 0.9

Is there any plan to support 0.9 any time soon?
as can be seen here it is now possible to have top-level key/values for things like tags and timestamp in the same level that database exists but I cannot find how to do it in current version of influxdb-client.

delete_series -- influxdb.client.InfluxDBClientError: 400: ... syntax error, unexpected OPERATION_EQUAL, expecting $end

I get the an exception when trying to delete a series using the python client. Here is a shell session demonstrating the problem. Based on the docs it looks like I'm using the module correctly.

>>> series = client.get_list_series()
>>> series
[u'grafana.dashboard_Y2FjaGUtbWV0cmljcw==', u'grafana.dashboard_Y2x1c3Rlci1oZWFsdGg=', u'grafana.dashboard_YWJvdXQ=', u'grafana.dashboard_d2VkZ2Vz', u'grafana.dashboard_dGFzay1tZXRyaWNz']
>>> client.delete_series(series[0])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/influxdb/client.py", line 418, in delete_series
    expected_response_code=204
  File "/usr/local/lib/python2.7/dist-packages/influxdb/client.py", line 161, in request
    raise InfluxDBClientError(response.content, response.status_code)
influxdb.client.InfluxDBClientError: 400: Error at 2126212:48 2126212:49. syntax error, unexpected OPERATION_EQUAL, expecting $end
>>> 

404 page not found with client.write_points

I installed InfluxDB on CentOS and trying to connect to it using Python, the error is below:

Python 2.7.8 (default, Mar 20 2015, 18:02:21) 
Type "copyright", "credits" or "license" for more information.

IPython 3.0.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: json_body = [ 
{ 'name': 'test', 'value': 4 } ]

In [2]: from influxdb import InfluxDBClient

In [3]: client = InfluxDBClient('localhost', 8086, 'root', 'root', 'database')

In [4]: client.write_points(json_body)
---------------------------------------------------------------------------
InfluxDBClientError                       Traceback (most recent call last)
<ipython-input-4-553a5e2d5c33> in <module>()
----> 1 client.write_points(json_body)

/usr/local/lib/python2.7/site-packages/influxdb-1.0.0-py2.7.egg/influxdb/client.pyc in write_points(self, points, time_precision, database, retention_policy)
    252                                   time_precision=time_precision,
    253                                   database=database,
--> 254                                   retention_policy=retention_policy)
    255 
    256     def _write_points(self,

/usr/local/lib/python2.7/site-packages/influxdb-1.0.0-py2.7.egg/influxdb/client.pyc in _write_points(self, points, time_precision, database, retention_policy)
    286             self.write(
    287                 data=data,
--> 288                 expected_response_code=200
    289             )
    290 

/usr/local/lib/python2.7/site-packages/influxdb-1.0.0-py2.7.egg/influxdb/client.pyc in write(self, data, params, expected_response_code)
    197             params=params,
    198             data=data,
--> 199             expected_response_code=expected_response_code
    200         )
    201         return True

/usr/local/lib/python2.7/site-packages/influxdb-1.0.0-py2.7.egg/influxdb/client.pyc in request(self, url, method, params, data, expected_response_code)
    188             return response
    189         else:
--> 190             raise InfluxDBClientError(response.content, response.status_code)
    191 
    192     def write(self, data, params=None, expected_response_code=200):

InfluxDBClientError: 404: 404 page not found

1: pip2.7 freeze
docopt==0.6.2
ecdsa==0.13
eventlet==0.17.1
greenlet==0.4.5
hp3parclient==3.2.0
httplib2==0.9
influxdb==1.0.0
ipython==3.0.0
meld3==1.0.0
paramiko==1.15.2
pycrypto==2.6.1
pyvmomi==5.5.0.2014.1.1
pyzmq==14.5.0
readline==6.2.4.1
requests==2.6.0
six==1.9.0
supervisor==3.1.3
tabulate==0.7.4
vconnector==0.3.7
vpoller==0.5.1

Any idea?

write_points method fails if called at exactly 5 second intervals

I'm experiencing a strange problem with the DB client that has taken a while to wrap my head around. Running a very simple logging script POSTing data to a remote database every five seconds (the five seconds is important), about one in 10 writes will fail throwing an requests.exceptions.ConnectionError.

Here is some example code that exhibits this behavior very consistently for me:

from influxdb import InfluxDBClient

client = InfluxDBClient('ADDRESS', 8086, 'USERNAME', 'PASSWORD', 'log', timeout=None)
json_body = [{
    "points": [],
    "name": "test.connectivity",
    "columns": ["time", "value", "errortype"]
}]
import time, calendar
while 1:
    inttime = calendar.timegm(time.gmtime())
    json_body[0]["points"].append([inttime, 1, None])
    try:
        client.write_points(json_body)
        print "Write succeeded"
        json_body[0]["points"] = []
    except Exception as e:
        print "Write failed: ", e, type(e)
        json_body[0]["points"][-1][1] = 0
        json_body[0]["points"][-1][2] = str(type(e))
    time.sleep(5)

The time.sleep(5) is important, because the following behavior only happens with a delay of five seconds between writes. Four seconds or six seconds don't have any problem. About every one in ten or so requests, the write_points call will throw an exception which prints out like this:

Write failed:  HTTPConnectionPool(host='ADDRESS', port=8086): Max retries exceeded with url: /db/log/series?p=PASSWORD&time_precision=s&u=USERNAME (Caused by <class 'httplib.BadStatusLine'>: '') <class 'requests.exceptions.ConnectionError'>

After watching the sequence of packets to influxDB in wireshark I've come to the conclusion that this issue is happening because of the way the requests library is being used.

If requests are sent at a greater than 5 second interval, each request is sent, receives a HTTP 200 OK and then exactly 5 seconds later a FIN, ACK packet arrives from the server closing the TCP connection. Each subsequent request then opens a brand new connection with a SYN before sending the POST.

For a request interval of less than five seconds, the HTTP requests keep the connection alive and a FIN is never received between database writes.

If the InfluxDB writing interval is exactly five seconds though (not a seemingly uncommon logging interval) the packet sequence looks like this (two requests, five seconds apart, second one failed):
screenshot from 2015-02-16 15 44 10

To me, it appears that the POST request from influxdb-python and the FIN, ACK from the influxdb server must be in flight at the same time, since the ACK of 402 is the same as the ACK that the remote server sent after the first POST was received and does not include the size of the second packet. Somehow this ends up being interpreted by the python client as an httplib.BadStatusLine which causes the unexpected exception to be thrown.

I understand that this is quite a complicated bug report for what seems like a simple issue, so thank you for taking the time to look over it. For now I'll just decrease my logging interval to four seconds to avoid this timing issue, but it seems like behavior that should be fixed to avoid trapping unsuspecting users of the client who might think they have connectivity issues or server problems when in reality the issue seems to be a very specific TCP state timing issue.

Time column in milliseconds

How to get the time column values in milliseconds?

I've the correct time when the query is executed directly in influxdb -> 1425821874508

Whereas from the python the query returns 1425821874.

Is the python module limited here?

Rename get_database_list to get_list_database

For the sake of consistency: get_database_list should be renamed get_list_database (although the former is more natural).

As for #79 this would be minor breaking change that can wait a major release (and have an alias in the meantime).

influxdb.client.InfluxDBClientError: 400: json: error calling MarshalJSON for type time.Time: Time.MarshalJSON: year outside of range [0,9999]

I am trying to write data with an explicit timestamp. I'm pretty confident that my timestamp is what InfluxDB usually takes (milliseconds since the epoch).

Some test code:

json_body = [{
    "points": [
        (1419240960000, 0, 0, 57),
        (1419241020000, 0, 0, 57),
        (1419241080000, 0, 0, 57),
        (1419241140000, 0, 0, 57),
        (1419241200000, 0, 0, 57)],
    "name": "metrics",
    "columns": ["time", "sequence_number", "users", "messages"]
}]
iclient.write_points(json_body)

This is the error I get:

influxdb.client.InfluxDBClientError: 400: json: error calling MarshalJSON for type time.Time: Time.MarshalJSON: year outside of range [0,9999]

This looks a lot like the client is expecting a time object instead of an integer. It would be neat if this could be documented or covered in the examples somewhere. And/or the client could behave more tolerant here and simply accept ints as timestamps, too.

Dataframe client silently drops additional results

Just got bitten by unexpected behavior with the dataframe client:

        if len(result) > 0:
            return self._to_dataframe(result[0], time_precision)
        else:
            return result

The impact is that results across multiple time series, in which len(result)>0, are discarded and only the first one is returned as a dataframe.

Would it make sense to return a list of data frames in this case? Actually, perhaps it would be better to return one stacked dataframe, in which the timeseries name is a column.

Thanks!

404 Errors in Windows

I've installed python-influxdb on my windows machine running python 2.7.9. Installation was successful, but issuing any influxDB command results in a 404 page not found error. The server is accessible and commands work using python-influxdb on Linux, but failed on two different windows PCs, one running Win 8.1 and the other running Windows Server 2008.

C:\InfluxDB>python
Python 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

from influxdb import InfluxDBClient
json_body = [
... {
... "name" : "cpu_load_short",
... "tags" : {
... "host": "server01",
... "region": "us-west"
... },
... "timestamp":"2009-11-10T23:00:00Z",
... "fields": {
... "value": 0.64
... }
... }
... ]
client = InfluxDBClient('10.196.212.98', 8086, 'root','root','example')
client.create_database('example')
Traceback (most recent call last):
File "", line 1, in
File "build\bdist.win-amd64\egg\influxdb\client.py", line 305, in create_database
File "build\bdist.win-amd64\egg\influxdb\client.py", line 227, in query
File "build\bdist.win-amd64\egg\influxdb\client.py", line 191, in request
influxdb.client.InfluxDBClientError: 404: 404 page not found

create_retention_policy does not allow numbers or spaces in name field

influxdb_client.create_retention_policy(name="7", duration="7d", replication=1)

InfluxDBClientError: 400: {"error":"error parsing query: found 7, expected identifier at line 1, char 25"}
influxdb_client.create_retention_policy(name="hello world", duration="7d", replication=1)

InfluxDBClientError: 400: {"error":"error parsing query: found world, expected ON at line 1, char 31"}

Bug in influxdb client for python

Exception in thread Thread-9:

Traceback (most recent call last):

File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner

self.run()

File "/usr/lib/python2.7/threading.py", line 505, in run

self.__target(_self.__args, *_self.__kwargs)

File "/usr/lib/python2.7/multiprocessing/pool.py", line 376, in _handle_results

task = get()

TypeError: ('init() takes exactly 3 arguments (2 given)', <class 'influxdb.influxdb08.client.InfluxDBClientError'>, ("400: invalid character '\r' in string literal",))

Tighten up format_query_response in client.py

  • Use dict.get with defaults of [] instead of testing for existence; reduces code nesting levels.
  • Use Python zip builtin to stitch columns and values together instead of explicit loop. (May provide some perf benefits too, since zip will run in compiled code instead of current Python loops.)
  • sort tags by key - no guarantee what order keys will be returned.
    @staticmethod
    def format_query_response(response):
        """Returns a list of items from a query response"""
        series = {}
        for result in response.get('results',[]):
            for row in result.get('series',[]):
                items = []
                if 'name' in row:
                    name = row['name']
                    tags = row.get('tags', None)
                    if tags:
                        name = (row['name'], tuple(sorted(tags.items())))
                    assert name not in series
                    series[name] = items
                else:
                    series = items  # Special case for system queries

                columns = row.get('columns',[])
                values = row.get('values',[])
                items.extend(dict(zip(columns, value)) for value in values)

        return series

SELECT with GROUP BY a tag return only 1 row

If you have a serie with distinct tags value then "SELECT * FROM serie_name GROUP BY a_tag_name" only returns one result : while it should returns one for each distinct serie_name:a_tag_name couple..

it's (I think) all is within the format_query_response() function which I have to analyse a bit to see how to handle correctly that..

database creation name encoding problems

I'm testing the v0.90 branch, and I get the following error when I create a db with characters like - or |.

influxdb_client.create_database("not-valid")

InfluxDBClientError('400: {"error":"error parsing query: found -, expected ;, EOF at line 1, char 23"}',)

Document batch_size for write_points

This is currently not documented. Also state that the data needs to be part of kwargs, since write_points(data, batch_size=10000) won't work.

HTTPS support

The http scheme seems to be hard-coded, with no way to override.

TODO

TODO LIST

  • Review the docs
  • Update and test all the tutorials
  • Fix the DataFrameClient and improve coverage (see #108 )
  • Implement more operations (user management, etc.)

DONE

  • Debug UDP support (I couldn't get it working)
  • Fix the SeriesHelper
  • Support writing in batch (see #102)

batch_size logic in write_points too soon leaves the loop

Hi,

I might be wrong, thus I'm just asking it here.
I believe, the merge from #20 contains a bug in the return True

        batch_size = kwargs.get('batch_size')
        if batch_size:
            for item in data:
                name = item.get('name')
                columns = item.get('columns')
                point_list = item.get('points')

                for batch in list_chunks(point_list, batch_size):
                    item = [{
                        "points": batch,
                        "name": name,
                        "columns": columns
                    }]
                    self._write_points(
                        data=item,
                        time_precision=time_precision)

                return True

        return self._write_points(data=data, time_precision=time_precision)

If data has more than one item, they are left out

This one has correct logic:
https://github.com/influxdb/influxdb-python/blob/master/influxdb/dataframe_client.py

Release 0.1.13

@jvshahid

A couple of bugs were fixed. We should release 0.1.13.

Can I just tag? Travis will do the release?

404 error with Influxdb-python 1.0 and Influxdb 0.8.8

I have a database called 'glances' on my Influxdb server:

$ influxdb-cli -d glances
glances> Connecting to http://localhost:8086/db/glances ...
glances> ✔ ready
glances> list series
┌──────┬────────────────────────┐
│ time │ name                   │
├──────┼────────────────────────┤
│ 0    │ cpu                    │
│ 0    │ diskio                 │
│ 0    │ fs                     │
│ 0    │ load                   │
│ 0    │ localhost.cpu          │
│ 0    │ localhost.diskio       │
│ 0    │ localhost.fs           │
│ 0    │ localhost.load         │
│ 0    │ localhost.mem          │
│ 0    │ localhost.memswap      │
│ 0    │ localhost.network      │
│ 0    │ localhost.processcount │
│ 0    │ mem                    │
│ 0    │ memswap                │
│ 0    │ network                │
│ 0    │ processcount           │
└──────┴────────────────────────┘
Query took  5 ms

But i raise a 404 error if i try to use Influxdb-python 1.0:

$ ipython
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 

In [1]: import influxdb

In [2]: influxdb.__version__
Out[2]: '1.0.0'

In [3]: influxdb.InfluxDBClient(database='glances').get_list_database()
---------------------------------------------------------------------------
InfluxDBClientError                       Traceback (most recent call last)
<ipython-input-3-16de30d78c8d> in <module>()
----> 1 influxdb.InfluxDBClient(database='glances').get_list_database()

/usr/local/lib/python2.7/dist-packages/influxdb/client.pyc in get_list_database(self)
    297         Get the list of databases
    298         """
--> 299         return [db['name'] for db in self.query("SHOW DATABASES")]
    300 
    301     def create_database(self, dbname):

/usr/local/lib/python2.7/dist-packages/influxdb/client.pyc in query(self, query, params, expected_response_code, database, raw)
    225             params=params,
    226             data=None,
--> 227             expected_response_code=expected_response_code
    228         )
    229 

/usr/local/lib/python2.7/dist-packages/influxdb/client.pyc in request(self, url, method, params, data, expected_response_code)
    189             return response
    190         else:
--> 191             raise InfluxDBClientError(response.content, response.status_code)
    192 
    193     def write(self, data, params=None, expected_response_code=200):

InfluxDBClientError: 404: 404 page not found

Any idea ?

`chunked` parameter in query method doesn't work

It seems that this library will just try to parse as json the full string, once it all comes down, which:

  • defeats the purpose of streaming the chunks
  • won't work, since there will be many JSON objects in the stream

I'm not sure that this is really possible using requests without jumping through some crazy hoops.

Upload 0.2.0

@toddboom

Hi! Can you please upload 0.2.0 to pypi?

Also, can I have the permissions to upload it? My username on pypi is reazem.

Thanks!

Docs don't build

Docs don't build right now. Could I be added as an owner on the readthedocs project? I could debug it. My username on readthedocs is ReAzem.

Todo:

  • Fix the docs build
  • Add job on travis to test that the docs build (done in cb1d07e)

/cc @jvshahid @areski

update: The docs build fine on my machine. So it has to do with the readthedocs project configuration.

0.9rc14 : get_database_list InfluxDBClientError

influxdb 0.9rc14

pip list | grep influxdb
influxdb (1.x)

...
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1562, in call                                    
                  **cdata['kwargs'])                                                                                         
                File "/usr/lib/python2.7/dist-packages/salt/states/influxdb_user.py", line 47, in present                    
                  database, user, password, host, port):                                                                     
                File "/usr/lib/python2.7/dist-packages/salt/modules/influx.py", line 115, in db_exists                       
                  dbs = db_list(user, password, host, port)                                                                  
                File "/usr/lib/python2.7/dist-packages/salt/modules/influx.py", line 86, in db_list                          
                  return client.get_database_list()                                                                          
              AttributeError: 'InfluxDBClient' object has no attribute 'get_database_list'                                   
     Started: 20:23:22.023236

Drop custom json.dumps logic

https://github.com/influxdb/influxdb-python/blob/df7fa9646b56a775c0494aadb3ea1ae41deb1ed8/influxdb/client.py#L143

This code could be replaced by just using request's json=... keyword argument, which is converted to a JSON string inside requests. This would require that all occurences of data=...somedict... in the code be replaced by json=...somedict....

There actually doesn't seem to be any case of data being a string in the code base. This means that all the logic testing for str could be stripped from the client and the tests.

Parse DSN instead of connection parameters

It is a very common pattern to allow hostname to be a DSN e.g.

  • influxdb://myuser:mypassword@localhost:8086/databasename
  • udp+influxdb://myuser:mypassword@localhost:8086/databasename
  • https+influxdb://myuser:mypassword@localhost:8086/databasename

Python provides the urlparse module that can be used to parse DSNs.

time_precision=m will be disabled in future release, use time_precision=ms isntead

I'm getting this message on influxdb log

[2014/08/21 09:21:25 UTC] [WARN] (api/http.TimePrecisionFromString:268) time_precision=m will be disabled in future release, use time_precision=ms isntead

but if I do just that on the python client I get an error:

Traceback (most recent call last):
(...)
  File "/usr/local/lib/python2.7/dist-packages/influxdb/client.py", line 74, in write_points_with_precision
    "Invalid time precision is given. (use 's','m' or 'u')")
Exception: Invalid time precision is given. (use 's','m' or 'u')

Helpers for writing series

I'll be working on the following from here.

A class ought to help developers avoid mistakes when creating the JSON for the write_points method, while also enable automatic bulk writes.

Initial helper class to be used as follows (comments wanted).

# Definition
class Event(InfluxDBHelper):
    class Meta:
        # server_name to be set for each event on commit.
        series_name = "event.stats.{server_name}"
        # Explicit.
        fields = ["time", "server_name", "sequence_number", "line"]
        # Raise an exception if a defined field is missing or additional fields provided.
        enforce_fields = False
        # Defines how many items should be stacked before a write request.
        bulk_size = 50
        # Commit if object is constructed with all fields defined in `fields`.
        auto_commit = False 

# Usage
# -- The three following are equivalent.
event = Event(**{"time": 1400425947368, "server_name": "us.east-1", "line": "some string"})
# or
event = Event(time=1400425947368, server_name="us.east-1", line="some string")
# or
event = Event()
event.time = 1400425947368
event.server_name = "us.east-1"
event.line = "some string"

# Set record in memory and will be committed when the bulk size is reached.
event.commit()

# Force commit of all items waiting for bulk size.
Event.commit_all() # Note that we're calling the class.

cannot drop database with / in name

I was able to create a database containing a "/" in the name, and then tried dropping the database- I received this error:

*** InfluxDBClientError: 400: {"error":"error parsing query: found /, expected ;, EOF at line 1, char 23"}

(I'm using the latest code from the 0.90 branch)

how do I get this working on 2.7..

install via pip
ran the tox command
im unfamilar with tox....
this is what I get in the interpreter.

from influxdb import InfluxDBClient
Traceback (most recent call last):
File "", line 1, in
File "influxdb/init.py", line 2, in
from influxdb.client import InfluxDBClient
File "influxdb/client.py", line 7, in
from six.moves.urllib.parse import urlencode
ImportError: No module named urllib.parse

i understand that mod is a 3.3 module..

So, is this only to be used with python 3.3?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.