I just wanted to get some data from my influx db using the “get Request” Node. In Python it works fine, but with the KNIME node I end up with an empty body.
So probably I’m doing something wrong
So this code I use within a python node to get the data:
# This example script simply outputs the node's input table.
import knime.scripting.io as knio
import requests
import pandas as pd
# local IP from my RASPI
url = 'http://192.168.178.77:8086/query'
params = {
'db': 'iobroker',
'q': 'SELECT time, value FROM "sonoff.0.DVES_CE8F07.MT691_Power_cur"'
}
response = requests.get(url, params=params)
print(response.request.url)
data = response.json()
# Postprocess Data
result = data['results'][0]
columns = result['series'][0]['columns']
values = result['series'][0]['values']
# create Dataframe from data
df = pd.DataFrame(values, columns=columns)
knio.output_tables[0] = knio.Table.from_pandas(df)
I’m not very experienced with the “requests” API so probably I’m missing some proper settings in the header section, am I?