# How can I get the Row URL to use it in a python script

**URL:** <https://forum.seatable.com/t/how-can-i-get-the-row-url-to-use-it-in-a-python-script/6033>\
**Category:** Scripts (Python and JS)\
**Created:** [December 6, 2024, 10:38am UTC](https://forum.seatable.com/t/how-can-i-get-the-row-url-to-use-it-in-a-python-script/6033 "2024-12-06T10:38:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sonja](https://forum.seatable.com/letter_avatar_proxy/v4/letter/s/977dab/32.png) [@Sonja](https://forum.seatable.com/u/Sonja)\
**Post date:** [December 6, 2024, 10:38am UTC](https://forum.seatable.com/t/how-can-i-get-the-row-url-to-use-it-in-a-python-script/6033/1 "2024-12-06T10:38:24Z")

</div>

I use a python script to generate a QR code per row. Which really works without any problems.

But my QR Codes should be the exact row URL, so I can scan it to find this entry.

Unfortunately I don’t know where I can find a kind of dictionary how to name such easy things, so I’m lost.

The way I can do this is by copying the each url and paste it in a column and the use this column in my python script.  
But there should be a faster way than copy-paste 200 url

Thank you for any help

Here is the python script I use:

import os  
import time  
import qrcode  
from seatable\_api import Base, context

api\_token = context.api\_token or “…”  
server\_url = context.server\_url or “[https://cloud.seatable.io](https://cloud.seatable.io)”

STRING\_COLUMN = “link” # text column which is expected to be transferred into qrcode  
# but instead I want to directly refer to the url  
IMAGE\_COLUMN = “QR Code”  
TABLE\_NAME = “2023\_CRM”  
OVERWRITE = True # set to True to overwrite existing barcode images

base = Base(api\_token, server\_url)  
base.auth()

qr = qrcode.QRCode(  
version=2,  
error\_correction=qrcode.constants.ERROR\_CORRECT\_L,  
box\_size=40,  
border=8  
)

def get\_time\_stamp():  
return str(int(time.time() \* 100000))

def main():  
for row in base.list\_rows(TABLE\_NAME):  
if not OVERWRITE and row.get(IMAGE\_COLUMN):  
print(“Skipping row. Image already exists.”)  
continue

```
try:
  row_id = row.get('_id')
  message = row.get(STRING_COLUMN) # what can I write here to use the row url directly without copy-paste it beforehand in this column?

  if not message:
    print("Skipping row. Empty message.")
    continue

  # clear, add data and make an qrcode object
  qr.clear()
  qr.add_data(str(message))
  qr.make()

  img = qr.make_image(fill_color="black", back_color="white")

  save_name = f"{row_id}_{get_time_stamp()}"
  img.save(f"/tmp/{save_name}.png")

  # temporarily saved as an image
  info_dict = base.upload_local_file(f"/tmp/{save_name}.png", name=None, file_type='image', replace=True)
  img_url = info_dict.get('url')
  base.update_row(TABLE_NAME, row_id, {IMAGE_COLUMN: [img_url]})

  # remove the image file which is saved temporarily
  os.remove(f"/tmp/{save_name}.png")
except Exception as exception:
  print("Error occurred during Image generation:", exception)
  continue

```

if **name** == “ **main** ”:  
main()

---

<div class="post-metadata">

**Author:** ![rdb](https://forum.seatable.com/user_avatar/forum.seatable.com/rdb/32/1869_2.png) [@rdb](https://forum.seatable.com/u/rdb)\
**Post date:** [December 6, 2024, 3:35pm UTC](https://forum.seatable.com/t/how-can-i-get-the-row-url-to-use-it-in-a-python-script/6033/2 "2024-12-06T15:35:55Z")

</div>

The row ID is indispensable for working with records in SeaTable.

There are various ways to obtain the row ID of a record:

- You can use the rowid() function in a formula column.
- You can query the database using the base.query([Rows - SeaTable Developer Manual](https://developer.seatable.io/scripts/python/objects/rows/#get-row-rows)) method.
- You can use the [context object](https://developer.seatable.io/scripts/python/objects/context/#current_row).

---

<div class="post-metadata">

**Author:** ![system](https://forum.seatable.com/uploads/default/original/1X/04603423fe81a46c321283663086c475429e8ccb.png) [@system](https://forum.seatable.com/u/system)\
**Post date:** [December 10, 2024, 10:01am UTC](https://forum.seatable.com/t/how-can-i-get-the-row-url-to-use-it-in-a-python-script/6033/3 "2024-12-10T10:01:58Z")

</div>

Closed on December 10, 2024, 10:01am UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
