influxdata / influxdb-python

Python client for InfluxDB
MIT License
1.69k stars 520 forks source link

Adding multiple fields by using dict type doesn't work #898

Open moweigel opened 3 years ago

moweigel commented 3 years ago

I'm not able to spot my mistake adding data to my InfluxDB by using the following scheme:

    from influxdb_client import InfluxDBClient
    import datetime
    from influxdb_client.client.write_api import ASYNCHRONOUS

    client_db = InfluxDBClient(url=f"http://{ip}:{port_db}", token=token, org=org)
    write_api = client_db.write_api(write_options=ASYNCHRONOUS)

    data = {
              "measurement": "title",
              "time": datetime.datetime.now().strftime("%m/%d/%y %H:%M:%S.%f"),
              "fields": db_dict    
           }    

    write_api.write(bucket=bucket, org=org, record=data)

where db_dict is a dictionary with multiple key:value entries. I don't receive any error but my DB remains without entries. It worked out fine before following this pattern - not this time. The titles of measurement and field of my inserted data are also displayed. I even tried varying with a time offset but didn't solve the problem. Any ideas whats the issue here? Thankful for every hint.