InfluxDB-Python 操作实践

博客介绍了Python连接数据库及基本操作,内容转载自https://www.cnblogs.com/prometheus-python-xshell/p/10943836.html ,聚焦于信息技术中Python与数据库的结合应用。

1、连接数据库及基本操作

 1 from influxdb import InfluxDBClient
 2 
 3 json_body = [
 4     {
 5         "measurement": "cpu_load_short",
 6         "tags": {
 7             "host": "server01",
 8             "region": "us-west"
 9         },
10         "time": "2009-11-10T23:00:00Z",
11         "fields": {
12             "value": 0.64
13         }
14     }
15 ]
16 client = InfluxDBClient('localhost', 8086, 'admin', 'admin', 'shuwh')
17 client.create_database('shuwh')
18 client.write_points(json_body)
19 result = client.query("select * from cpu_load_short;")
20 print "Result: {0}".format(result)

Result: ResultSet({'(u'cpu_load_short', None)': [{u'host': u'server01', u'region': u'us-west', u'value': 0.64, u'time': u'2009-11-10T23:00:00Z'}]})

 

转载于:https://www.cnblogs.com/prometheus-python-xshell/p/10943836.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值