Skip to content
Snippets Groups Projects
Commit eb2c5b93 authored by Kenny Gao's avatar Kenny Gao
Browse files

Python Code used to query DB

Uses InfluxDBClient python code to query the test influxDB database
parent 4d7600cc
No related branches found
No related tags found
1 merge request!2Order form
from influxdb import InfluxDBClient
from io import StringIO
def getData(site, inst, symbols, begin, end, value):
host = 'bikini'
port = 8086
username = 'root'
password = 'root'
DB = 'davidh'
query = StringIO()
query.write('select ' + value + ' FROM ')
idx = 0
for symbol in symbols:
if idx == len(symbols) - 1:
query.write(symbol + ' ')
else:
query.write('davidh.one_year.' + symbol + ', ')
idx += 1
query.write('WHERE time >= \'' + begin + '\' AND time <= \'' + end + '\'')
query.write(' AND inst=\'' + inst + '\' AND site=\'' + site + '\'')
#query.write("GROUP BY time(" + interval + ")")
client = InfluxDBClient(host, port, username, password, DB)
result = client.query(query.getvalue())
print(result)
return result
getData('aoss', 'tower', ['air_temp', 'rh', 'dewpoint', 'accum_precip', 'pressure', 'altimeter', 'solar_flux'], '2016-04-21T18:00:00Z', '2016-04-21T19:00:00Z', 'value_1m')
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment