Python中使用InfluxDBClient类操作数据库 示例如下
# 数据库常用函数 client InfluxDBClient( localhost , 8086, root , root , example ) client.get_list_database() # 显示所有数据库名称 client.create_database( example ) # 创建数据库 client.drop_database( example ) # 删除数据库数据表操作完整示例如下
from influxdb import InfluxDBClient
json_body [
measurement : cpu_load_short ,
tags : {
host : server01 ,
region : us-west
time : 2009-11-10T23:00:00Z ,
fields : {
value : 0.64
client InfluxDBClient( localhost , 8086, root , root , example )
client.create_database( example )
client.write_points(json_body)
result client.query( select value from cpu_load_short; )
print( Result: {0} .format(result))
db操作知识点
更新
tags 和 timestamp相同时数据会执行覆盖操作 相当于InfluxDB的更新操作。
删除
client.query( delete from cpu_load_short; ) # 删除数据
数据存储格式
json_body [
measurement : cpu_load_short ,
tags : {
host : server01 ,
region : us-west
time : 2009-11-10T23:00:00Z ,
fields : {
value : 0.64


