栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

数据监控系统的架构与搭建实践

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

数据监控系统的架构与搭建实践

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
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/267571.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号