首页 文章

Windows InfluxDB与AWS InfluxDB之间的交互

提问于
浏览
0

关于InfluxDB和Python的交互,我遇到了以下问题 .

InfluxDB安装在Windows 7机器上,我也有InfluxDB,它安装在AWS ubuntu机器的docker容器中 . 我将InfluxDB端口从AWS机器转发到我的本地Windows机器 .

然后,使用Python influxdb库我尝试以下列方式连接到InfluxDB-s:

client_aws = influxdb.InfluxDBClient('localhost', 8087, '', '', 'aws_db')
client_local = influxdb.InfluxDBClient('localhost', 8086, '', '', 'local_db')

然后,我只想将AWS机器上的数据写入我的本地机器:

query = 'select field_name from test_aws'
rs = client_aws.query(query, params={"epoch": "us"})
points = list(rs.get_points(measurement="test_aws"))
db_body = [ { "measurement": "test_local",
              "time": query_time,
              "fields": { field_name: points[0].get("field_name") } } ]
client_local.write_points(db_body)

之后我检查了我的本地InfluxDB并检测到没有测量“test_local”但执行查询

select field_name from test_local

返回必要的数据 . 此外,我不能放弃测量test_local,因为本地InfluxDB不存在 .

请问你能帮帮我吗?我的数据存储在哪里?如何执行查询但没有测量?

1 回答

  • 0

    可以执行查询,但不返回任何数据 .

    在尝试向其中插入数据之前,需要确保目标数据库存在于localhost计算机上 .

    在尝试将数据插入 db_local 之前添加对 client.create_database('local_db') 的调用以确保数据库存在 .

相关问题