# Influxdb python sending multiple values

**URL:** <https://community.influxdata.com/t/influxdb-python-sending-multiple-values/26058>\
**Category:** Systems\
**Tags:** influxdb, client-libraries, python\
**Created:** [August 8, 2022, 8:23am UTC](https://community.influxdata.com/t/influxdb-python-sending-multiple-values/26058 "2022-08-08T08:23:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bra1nsen](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/bra1nsen/32/10363_2.png) [@Bra1nsen](https://community.influxdata.com/u/Bra1nsen)\
**Post date:** [August 8, 2022, 8:23am UTC](https://community.influxdata.com/t/influxdb-python-sending-multiple-values/26058/1 "2022-08-08T08:23:32Z")

</div>

I have multiple measurements: temperature, humidity, wind, co2 etc.  
I use the following script, how can i send multiple records?

```auto
import influxdb_client
from influxdb_client.client.write_api import SYNCHRONOUS

bucket = "<my-bucket>"
org = "<my-org>"
token = "<my-token>"
# Store the URL of your InfluxDB instance
url="https://us-central1-1.gcp.cloud2.influxdata.com"

client = influxdb_client.InfluxDBClient(
    url=url,
    token=token,
    org=org
)

write_api = client.write_api(write_options=SYNCHRONOUS)

p = influxdb_client.Point("my_measurement").tag("location", "Prague").field("temperature", 25.3)
write_api.write(bucket=bucket, org=org, record=p)

```

---

<div class="post-metadata">

**Author:** ![Jay\_Clifford](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jay_clifford/32/8287_2.png) [@Jay\_Clifford](https://community.influxdata.com/u/Jay_Clifford)\
**Post date:** [August 8, 2022, 10:15am UTC](https://community.influxdata.com/t/influxdb-python-sending-multiple-values/26058/2 "2022-08-08T10:15:52Z")

</div>

Hi @Bra1nsen,  
You have a few options available to you:

```auto
        """
        Write Line Protocol formatted as string
        """
        _write_client.write("my-bucket", "my-org", ["h2o_feet,location=coyote_creek water_level=2.0 2",
                                                    "h2o_feet,location=coyote_creek water_level=3.0 3"])

        """
        Write Line Protocol formatted as byte array
        """
        _write_client.write("my-bucket", "my-org", "h2o_feet,location=coyote_creek water_level=1.0 1".encode())
        _write_client.write("my-bucket", "my-org", ["h2o_feet,location=coyote_creek water_level=2.0 2".encode(),
                                                    "h2o_feet,location=coyote_creek water_level=3.0 3".encode()])

        """
        Write Dictionary-style object
        """
        _write_client.write("my-bucket", "my-org", [{"measurement": "h2o_feet", "tags": {"location": "coyote_creek"},
                                                     "fields": {"water_level": 2.0}, "time": 2},
                                                    {"measurement": "h2o_feet", "tags": {"location": "coyote_creek"},
                                                     "fields": {"water_level": 3.0}, "time": 3}])

        """
        Write Data Point
        """
        _write_client.write("my-bucket", "my-org",
                            [Point("h2o_feet").tag("location", "coyote_creek").field("water_level", 5.0).time(5),
                             Point("h2o_feet").tag("location", "coyote_creek").field("water_level", 6.0).time(6)])

        """
        Write Observable stream
        """
        _data = rx \
            .range(7, 11) \
            .pipe(ops.map(lambda i: "h2o_feet,location=coyote_creek water_level={0}.0 {0}".format(i)))

        _write_client.write("my-bucket", "my-org", _data)

        """
        Write Pandas DataFrame
        """
        _now = datetime.utcnow()
        _data_frame = pd.DataFrame(data=[["coyote_creek", 1.0], ["coyote_creek", 2.0]],
                                   index=[_now, _now + timedelta(hours=1)],
                                   columns=["location", "water_level"])

        _write_client.write("my-bucket", "my-org", record=_data_frame, data_frame_measurement_name='h2o_feet',
                            data_frame_tag_columns=['location'])

```

Essentially if you want to keep using the point object you store them within an array. then point the record parameter at the array.

---

<div class="post-metadata">

**Author:** ![Bra1nsen](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/bra1nsen/32/10363_2.png) [@Bra1nsen](https://community.influxdata.com/u/Bra1nsen)\
**Post date:** [August 8, 2022, 1:36pm UTC](https://community.influxdata.com/t/influxdb-python-sending-multiple-values/26058/3 "2022-08-08T13:36:38Z")

</div>

thanks for reply jay =)

decided for data point methodology:

```auto
write_api.write(bucket=bucket, org=org, [Point("Rotations").field("rotations", rot),Point("VaneValue").field("vane_value", vv),Point("Winddirection").field("wind_direction", wdir),Point("Pressure").field("air_pressure", mbar),Point("Humidity").field("humidity", hum),Point("Temperature").field("temperature", temp)])														 

```

any idea whats wrong there?  
cant spot the mistake =(

```auto
File "/home/pi/arduinoDB.py", line 65
    write_api.write(bucket=bucket, org=org, [Point("Rotations").field("rotations", rot),Point("VaneValue").field("vane_value", vv),Point("Winddirection").field("wind_direction", wdir),Point("Pressure").field("air_pressure", mbar),Point("Humidity").field("humidity", hum),Point("Temperature").field("temperature", temp)]) 
                                                                                                                                                                                                                                                                                                                               ^
SyntaxError: positional argument follows keyword argument

```

---

<div class="post-metadata">

**Author:** ![Jay\_Clifford](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jay_clifford/32/8287_2.png) [@Jay\_Clifford](https://community.influxdata.com/u/Jay_Clifford)\
**Post date:** [August 8, 2022, 2:42pm UTC](https://community.influxdata.com/t/influxdb-python-sending-multiple-values/26058/5 "2022-08-08T14:42:06Z")

</div>

> [@Bra1nsen](#):
>
> `write_api.write(bucket=bucket, org=org, [Point("Rotations").field("rotations", rot),Point("VaneValue").field("vane_value", vv),Point("Winddirection").field("wind_direction", wdir),Point("Pressure").field("air_pressure", mbar),Point("Humidity").field("humidity", hum),Point("Temperature").field("temperature", temp)])`

Hi @Bra1nsen,  
Sorry, that could have been my mistake with positional arguments. Could you try this:

```auto
write_api.write(bucket=bucket, org=org, record=[Point("Rotations").field("rotations", rot),Point("VaneValue").field("vane_value", vv),Point("Winddirection").field("wind_direction", wdir),Point("Pressure").field("air_pressure", mbar),Point("Humidity").field("humidity", hum),Point("Temperature").field("temperature", temp)])

```

---

<div class="post-metadata">

**Author:** ![Jay\_Clifford](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jay_clifford/32/8287_2.png) [@Jay\_Clifford](https://community.influxdata.com/u/Jay_Clifford)\
**Post date:** [August 8, 2022, 2:43pm UTC](https://community.influxdata.com/t/influxdb-python-sending-multiple-values/26058/6 "2022-08-08T14:43:12Z")

</div>

Also looking at your line protocol. I would strongly recommend keeping all these fields under one measurement. This will make your life a lot easier querying the data.

Here is an example:

```auto
        _write_client.write(bucket="generators", record=[Point("machine").tag("name", "machine_1").field("rotations", 5).field("vane_value", 2).field("wind_direction", 12).field("air_pressure", 1).field("humidity", 4).field("temperature", 5), 
                                                         Point("machine").tag("name", "machine_2").field("rotations", 5).field("vane_value", 2).field("wind_direction", 12).field("air_pressure", 1).field("humidity", 4).field("temperature", 5) ])

```
