To connect to a InfluxDB, you must create a
:py:class:`~influxdb.InfluxDBClient` object. The default configuration
connects to InfluxDB on localhost
with the default
ports. The below instantiation statements are all equivalent:
# Set INFLUXDB_NO_DATAFRAME_CLIENT to skip the expensive DataFrameClient # import in cases where you only need the basic InfluxDBClient. os.environ["INFLUXDB_NO_DATAFRAME_CLIENT"] = "1" from influxdb import InfluxDBClient # using Http client = InfluxDBClient(database='dbname') client = InfluxDBClient(host='127.0.0.1', port=8086, database='dbname') client = InfluxDBClient(host='127.0.0.1', port=8086, username='root', password='root', database='dbname') # using UDP client = InfluxDBClient(host='127.0.0.1', database='dbname', use_udp=True, udp_port=4444)
To write pandas DataFrames or to read data into a pandas DataFrame, use a :py:class:`~influxdb.DataFrameClient` object. These clients are initiated in the same way as the :py:class:`~influxdb.InfluxDBClient`:
from influxdb import DataFrameClient client = DataFrameClient(host='127.0.0.1', port=8086, username='root', password='root', database='dbname')
Note
Only when using UDP (use_udp=True) the connection is established.
.. currentmodule:: influxdb.InfluxDBClient
.. autoclass:: influxdb.InfluxDBClient :members: :undoc-members:
.. currentmodule:: influxdb.DataFrameClient
.. autoclass:: influxdb.DataFrameClient :members: :undoc-members:
.. currentmodule:: influxdb.SeriesHelper
.. autoclass:: influxdb.SeriesHelper :members: :undoc-members:
See the :ref:`resultset` page for more information.
.. currentmodule:: influxdb.ResultSet
.. autoclass:: influxdb.resultset.ResultSet :members: :undoc-members: