1

I'm connecting to an influx db using python. Using built in dataframe tools I am successfully accessing data and am able to do everything I'd like, accept I can't access the timestamp values. For example:

import sys
from influxdb import DataFrameClient

reload(sys)
sys.setdefaultencoding('utf-8')

user = 'reader'
password = 'oddstringtoconfusebadguys'
dbname = 'autoweights'
host = '55.777.244.112'
protocol = 'line'
port = 8086

client = DataFrameClient(host,port=8086,username=user,password=password,
database=dbname,verify_ssl=False,ssl=True)

results = client.query("select * from measurementname")

df = results['measurementname']

for index, row in df.iterrows():
     print row

results look like this

Name: 2017-11-14 22:11:23.534395882+00:00, dtype: object host C4:27:EB:D7:D9:70 value 327

I can easily access row['host'] and row['value']. The date/time stamp is obviously important but try as I might I can't find an approach to get the values.

1 Answers1

0

You can get the timestamp using the index not the row parameter

for index, row in df.iterrows():
    print(index)
    print(row)

You can also use Pinform library, an ORM for InfluxDB to easily get timestamp, fields and tags.

Sina Rezaei
  • 529
  • 3
  • 24