# Python client library : problem with writing new point in the bucket

**URL:** <https://community.influxdata.com/t/python-client-library-problem-with-writing-new-point-in-the-bucket/35376>\
**Category:** Systems\
**Created:** [August 20, 2024, 8:15am UTC](https://community.influxdata.com/t/python-client-library-problem-with-writing-new-point-in-the-bucket/35376 "2024-08-20T08:15:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lory\_96](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@Lory\_96](https://community.influxdata.com/u/Lory_96)\
**Post date:** [August 20, 2024, 8:15am UTC](https://community.influxdata.com/t/python-client-library-problem-with-writing-new-point-in-the-bucket/35376/1 "2024-08-20T08:15:20Z")

</div>

Hi there,

I’m using API get request to pull raw data from server , then fetch needed information and i use influxDB python client library to push data to my InfluxDB bucket.

The problem is each time value changes of varibale , the record of DB changes (timestamp and value updates). I want to have a new point (with different tiemstamp and value from previous one) each time this happens.

```auto
client = influxdb_client.InfluxDBClient(
    url=url,
    token=token,
    org=org,
    verify_ssl=False
    )

write_api = client.write_api(write_options=SYNCHRONOUS)

p = influxdb_client.Point(name_machine).tag(name_machine , name_machine).field("TCNZ1B3", TCNZ1B3)
write_api.write(bucket='twgdb', org=org, record=p)

```

 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/3X/5/f/5f0ea0780d456c845992fa67704a40d2baf5e0ee.png)  
any idea how to do this ? is there a way to write new point instead of updating previous one ?

---

<div class="post-metadata">

**Author:** ![suyash](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/suyash/32/15791_2.png) [@suyash](https://community.influxdata.com/u/suyash)\
**Post date:** [August 22, 2024, 12:54pm UTC](https://community.influxdata.com/t/python-client-library-problem-with-writing-new-point-in-the-bucket/35376/2 "2024-08-22T12:54:55Z")

</div>

Add a unique timestamp to create a new record instead of updating the existing one that way, InfluxDB will treat each point as a separate entry due to the different timestamps. Code changes you should try to make and test:

```auto
# Get current timestamp at microsecond precision if you prefer
current_time = int(datetime.utcnow().timestamp() * 1e9)

p = (
    influxdb_client.Point(name_machine)
    .tag(name_machine, name_machine)
    .field("TCNZ1B3", TCNZ1B3)
    .time(current_time)
)
write_api.write(bucket='twgdb', org=org, record=p)

```

---

<div class="post-metadata">

**Author:** ![Lory\_96](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@Lory\_96](https://community.influxdata.com/u/Lory_96)\
**Post date:** [August 22, 2024, 3:24pm UTC](https://community.influxdata.com/t/python-client-library-problem-with-writing-new-point-in-the-bucket/35376/3 "2024-08-22T15:24:44Z")

</div>

Thanks for your answer. I will test this. If i need to write 4 different variables (fields) per timestamp , do i need to write each point seperatly ? is it possible to write all data points in 1 batch using python client library ?

---

<div class="post-metadata">

**Author:** ![suyash](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/suyash/32/15791_2.png) [@suyash](https://community.influxdata.com/u/suyash)\
**Post date:** [August 22, 2024, 6:06pm UTC](https://community.influxdata.com/t/python-client-library-problem-with-writing-new-point-in-the-bucket/35376/4 "2024-08-22T18:06:30Z")

</div>

Really up to you, you can pass multiple points in a single list, something like this : `write_api.write(bucket='twgdb', org=org, record=[p1, p2, p3])`

---

<div class="post-metadata">

**Author:** ![Lory\_96](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@Lory\_96](https://community.influxdata.com/u/Lory_96)\
**Post date:** [August 22, 2024, 7:13pm UTC](https://community.influxdata.com/t/python-client-library-problem-with-writing-new-point-in-the-bucket/35376/5 "2024-08-22T19:13:24Z")

</div>

tha’s what i did but ended up with “failed to load tags” error  
 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/3X/2/3/23c44ea10b714279779fce412fe54fc867559de9.png)
