-
-
Save rossmcdonald/83e64ba61d1ec3e43f05e5568e7350e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import influxdb | |
host = 'my.influxdb.server' | |
port = 8086 | |
dbname = 'my_db' | |
def write_dicts(measurement, tagDict, fieldDict): | |
myclient = influxdb.InfluxDBClient(host=host, port=port, database=dbname) | |
# data is a list of points | |
data = [] | |
# p is a point, which includes a measurement, tags, and fields (and optionally time) | |
p={} | |
p['measurement']=measurement | |
p['tags']=tagDict | |
p['fields']=fieldDict | |
# Append our point to data | |
data.append(p) | |
myclient.write_points(data, time_precision='s') | |
if __name__ == "__main__": | |
# example for testing | |
tagDict={'tag1':'yes', 'tag2':'green'} | |
fieldDict={'val1':22.33, 'val2':-42.42} | |
write_dicts('my_measure', tagDict, fieldDict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment