Table of Contents
This script generates QR codes from text content (e.g., URLs, product IDs) stored in a SeaTable column and saves the resulting images back into an image column. You can control whether existing QR codes should be overwritten.
The complete script
from seatable_api import Base, context
import qrcode
from io import BytesIO
base = Base(context.api_token, context.server_url)
base.auth()
TABLE_NAME = "Table1"
TEXT_COLUMN = "URL"
IMAGE_COLUMN = "QR Code"
OVERWRITE = False
rows = base.list_rows(TABLE_NAME)
for row in rows:
text = row.get(TEXT_COLUMN)
existing = row.get(IMAGE_COLUMN)
if not text or (existing and not OVERWRITE):
continue
qr = qrcode.QRCode(version=2, error_correction=qrcode.constants.ERROR_CORRECT_M, box_size=10, border=4)
qr.add_data(text)
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
buf = BytesIO()
img.save(buf, format='PNG')
buf.seek(0)
info = base.upload_bytes_file(str(text) + '.png', buf.read(), file_type='image')
base.update_row(TABLE_NAME, row['_id'], {IMAGE_COLUMN: [info.get('url')]})
print("QR codes generated.")
Set OVERWRITE = True if you want to regenerate existing QR codes. Adjust TEXT_COLUMN and IMAGE_COLUMN to match your column names.
For the complete function reference, visit the SeaTable Developer Manual .