frominfluxdbimportInfluxDBClientimportdatetimeclient=InfluxDBClient('ip', 8086,) # 连接数据库client.create_database('test') # 创建数据库print(datetime.datetime.now()) defset_db(): points= [ # 待写入数据库的点组成的列表 { "measurement": "test", "time": datetime.datetime.now(), "tags": { "stuid": "s123", }, "fields": { "value": 0.64, "date":1 } } ] client.write_points(points, database='test') # 将这些点写入指定databaseprint(points) # 查询刚刚写入的点result=client.query('select value from test;', database='test') #print(result)if__name__=='__main__': whileTrue: set_db()