# Add tag to points using python client library

**URL:** <https://community.influxdata.com/t/add-tag-to-points-using-python-client-library/20123>\
**Category:** InfluxDB 2\
**Tags:** influxdb, python\
**Created:** [May 28, 2021, 1:40pm UTC](https://community.influxdata.com/t/add-tag-to-points-using-python-client-library/20123 "2021-05-28T13:40:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![eloparco](https://avatars.discourse-cdn.com/v4/letter/e/919ad9/32.png) [@eloparco](https://community.influxdata.com/u/eloparco)\
**Post date:** [May 28, 2021, 1:40pm UTC](https://community.influxdata.com/t/add-tag-to-points-using-python-client-library/20123/1 "2021-05-28T13:40:05Z")

</div>

Hello,  
I want to use the python client library to add a tag to all the records matching a query.  
That’s what I got so far, but it’s not working.

```python
client = InfluxDBClient(url=url, token=token, org=org)
write_api = client.write_api(write_options=SYNCHRONOUS)
query_api = client.query_api()

query = "<put_your_query_here>"
result = query_api.query(org=org, query=query)
for table in result:
    for record in table.records:
        record["ADDITIONAL_TAG"] = str(uuid.uuid4())
        write_api.write(bucket=bucket, org=org, record=record)

```

I want to avoid creating the point with `p = Point(...).tag(...).field(...)` because in that case I need to know the tags in advance since in the [docs](https://docs.influxdata.com/influxdb/cloud/tools/client-libraries/python/) I only see `values.get("<your tag>")` to retrieve tags.  
Thanks

---

<div class="post-metadata">

**Author:** ![bednar](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/bednar/32/3690_2.png) [@bednar](https://community.influxdata.com/u/bednar)\
**Post date:** [May 31, 2021, 11:06am UTC](https://community.influxdata.com/t/add-tag-to-points-using-python-client-library/20123/2 "2021-05-31T11:06:38Z")

</div>

Hi @eloparco,

The `write_api` doesn’t supports writes `FluxRecord` into InfluxDB.

The best option for you is to create a `dictionary` with values from `FluxRecord`. Something like:

```python
result = query_api.query('from(bucket:"my-bucket") |> range(start: -10m)')
for table in result:
for record in table.records:
    ignore = ['result', 'table', '_time', '_start', '_stop', '_field', '_measurement']

    # tags
    tag_names = [column.label for column in table.columns if column.group and column.label not in ignore]
    tags = {tag: record[tag] for tag in tag_names}
    tags["ADDITIONAL_TAG"] = str(uuid.uuid4())

    # fields
    field_names = [column.label for column in table.columns if not column.group and column.label not in ignore]
    fields = {field: record[field] for field in field_names}

    lp_dict = {
        "measurement": record["_measurement"],
        "tags": tags,
        "fields": fields,
        "time": record["_time"]
    }

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

```

Regards
