

InfluxDB-Python is a client for interacting with InfluxDB_.

.. image:: https://travis-ci.org/influxdb/influxdb-python.svg?branch=master
    :target: https://travis-ci.org/influxdb/influxdb-python

.. image:: https://readthedocs.org/projects/influxdb-python/badge/?version=latest&style
    :target: http://influxdb-python.readthedocs.org/
    :alt: Documentation Status

.. image:: https://img.shields.io/coveralls/influxdb/influxdb-python.svg
  :target: https://coveralls.io/r/influxdb/influxdb-python
  :alt: Coverage

.. image:: https://pypip.in/download/influxdb/badge.svg
    :target: https://pypi.python.org/pypi//influxdb/
    :alt: Downloads

.. image:: https://pypip.in/version/influxdb/badge.svg
    :target: https://pypi.python.org/pypi/influxdb/
    :alt: Latest Version

.. image:: https://pypip.in/py_versions/influxdb/badge.svg
    :target: https://pypi.python.org/pypi/influxdb/
    :alt: Supported Python versions

.. image:: https://pypip.in/license/influxdb/badge.svg
    :target: https://pypi.python.org/pypi/influxdb/
    :alt: License

.. _readme-about:

InfluxDB is an open-source distributed time series database, find more about InfluxDB_ at http://influxdb.com/


.. _installation:

InfluxDB v0.8.X users
=====================

InfluxDB 0.9 was released and it is the new recommended version. However, InfluxDB 0.8.x users may still use the legacy client by using ``from influxdb.influxdb08 import InfluxDBClient`` instead.

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.2, 3.3, 3.4, PyPy and PyPy3.

Main dependency is:

- Requests: HTTP library for human beings (http://docs.python-requests.org/)


Additional dependencies are:

- pandas: for writing from and reading to DataFrames (http://pandas.pydata.org/)
- Sphinx: Tool to create and manage the documentation (http://sphinx-doc.org/)
- Nose: to auto-discover tests (http://nose.readthedocs.org/en/latest/)
- Mock: to mock tests (https://pypi.python.org/pypi/mock)


Documentation
=============

InfluxDB-Python documentation is available at http://influxdb-python.readthedocs.org

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))

If you want to connect to a cluster, you could initialize a ``InfluxDBClusterClient``::

    $ python

    >>> from influxdb import InfluxDBClusterClient

    >>> cc = InfluxDBClusterClient(hosts = [('192.168.0.1', 8086),
                                            ('192.168.0.2', 8086),
                                            ('192.168.0.3', 8086)],
                                   username='root',
                                   password='root',
                                   database='example')

``InfluxDBClusterClient`` has the same methods as ``InfluxDBClient``, it basically is a proxy to multiple InfluxDBClients.

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/.


Development
===========

All development is done on Github_. Use Issues_ to report
problems or submit contributions.

.. _Github: https://github.com/influxdb/influxdb-python/
.. _Issues: https://github.com/influxdb/influxdb-python/issues


TODO
====

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


Source code
===========

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


.. _InfluxDB: http://influxdb.com/
.. _Sphinx: http://sphinx.pocoo.org/
.. _Tox: https://tox.readthedocs.org
