23 from influxdb
import InfluxDBClient
30 def __init__(self, user, password, dbname, host, port, bucket_size):
31 self.
client = InfluxDBClient(host, port, user, password, dbname)
36 self.
client.create_database(self.dbname)
39 self.
client.switch_database(self.dbname)
42 client.write_points(self.
bucket)
46 if len(self.
bucket) < bucket_size:
47 client.write_points(self.
bucket)
50 def main(host='localhost', port=8086):
51 now = datetime.datetime.today()
54 "measurement":
'meas0',
55 "time": now.isoformat(timespec=
'milliseconds')
64 db =
InfluxDB(USER, PASSWORD, DBNAME, host, port, 10000)
73 parser = argparse.ArgumentParser(
74 description=
'example code to play with InfluxDB')
75 parser.add_argument(
'--host', type=str, required=
False,
77 help=
'hostname influxdb http API')
78 parser.add_argument(
'--port', type=int, required=
False, default=8086,
79 help=
'port influxdb http API')
80 return parser.parse_args()
83 if __name__ ==
'__main__':
85 main(host=args.host, port=args.port)
def writePoint(self, point)
def __init__(self, user, password, dbname, host, port, bucket_size)
def main(host='localhost', port=8086)