Metadata-Version: 2.1
Name: ipython-flux
Version: 0.0.1
Summary: InfluxDB access via IPython
Home-page: https://pypi.python.org/pypi/ipython-flux
Author: Catherine Devlin
Author-email: robert.hajek@gmail.com
License: MIT
Keywords: ipython magic influxdb
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: Database
Classifier: Topic :: Database :: Front-Ends
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 2
Description-Content-Type: text/x-rst
Requires-Dist: prettytable (<1)
Requires-Dist: ipython (>=1.0)
Requires-Dist: influxdb-client
Requires-Dist: six
Requires-Dist: ipython-genutils (>=0.1.0)

============
ipython-flux
============
.. image:: https://circleci.com/gh/bonitoo-io/ipython-flux.svg?style=svg
    :target: https://circleci.com/gh/bonitoo-io/ipython-flux

:Author: Robert Hajek, Bonitoo.io

Introduces a %flux (or %%flux) magic.
Connect to a InfluxDB and run Flux commands within IPython or IPython Notebook.

.. image:: https://raw.github.com/bonitoo-io/ipython-flux/master/examples/example.png
   :width: 600px
   :alt: screenshot of ipython-flux in the Notebook

Examples
--------

.. code-block:: python

    In [1]: %load_ext flux

    In [2]: %%flux http://localhost:9999 --token my-token --org my-org
       ...: from(bucket: "apm_metricset")
       ...:   |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
       ...:   |> filter(fn: (r) => r["_measurement"] == "apm_metricset")
       ...:   |> filter(fn: (r) => r["_field"] == "samples_system.process.cpu.total.norm.pct")
       ...:
    Out[2]: ...

After the first connection, connect info can be omitted::

    In [3]: %flux
       ...: from(bucket: "apm_metricset")
       ...:   |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
       ...:   |> filter(fn: (r) => r["_measurement"] == "apm_metricset")
       ...:   |> filter(fn: (r) => r["_field"] == "samples_system.process.cpu.total.norm.pct")

    Out[8]: ...


If no connect string is supplied, ``%flux`` will provide a list of existing connections;
however, if no connections have yet been made and the environment variable ``INFLUXDB_V2_URL``
is available, that will be used.


Assignment
----------

Ordinary IPython assignment works for single-line `%flux` queries:

.. code-block:: python

    In [12]: result = %flux from(bucket: "apm_metricset")  |> range(start: 0)

The `<<` operator captures query results in a local variable, and
can be used in multi-line ``%%flux``:

.. code-block:: python

    In [19]: %%flux works << %flux from(bucket: "apm_metricset")
        ...: |> range(start: 0)
        ...:

Pandas
------

result is automatically converted into pandas dataframe

.. code-block:: python

    In [3]: result =  %flux from(bucket: "apm_metricset")  |> range(start: 0)

The ``--persist`` argument, with the name of a 
DataFrame object in memory, 
will create a measurement
in the database from the named DataFrame.  

.. code-block:: python

    In [5]: %flux --persist dataframe

    In [6]: %flux from(bucket: "apm_metricset")  | filter(fn: (r) => r["_measurement"] == "dataframe" |> range(start: 0)

.. _Pandas: http://pandas.pydata.org/

Options
-------

``-l`` / ``--connections``
    List all active connections

``-t`` / ``--token``
    InfluxDB token

``-o`` / ``--org``
    InfluxDB org

``-x`` / ``--close <session-name>`` 
    Close named connection 

``-p`` / ``--persist``
    Create a measurement in the database from the named DataFrame

``-f`` / ``--file <path>``
    Run Flux from file at this path

Installing
----------

Install the lastest release with::

    pip install ipython-flux

or download from https://github.com/bonitoo-io/ipython-flux and::

    cd ipython-flux
    sudo python setup.py install

Development
-----------

https://github.com/bonitoo-io/ipython-flux


News
----

0.0.1
~~~~~

*Release date: 21-07-2020*

* Initial release


