Skip to content
Back

Python TablesDB Rework

  • 0
  • Functions
  • Cloud
Chefe#8332
18 Mar, 2026, 14:30

Hi, i starting to rework some older functions to TablesDB list_rows Method. I used list_documents with a resultset with worked fine. Now i tried to get all rows from a specific table and have the data in it. So i started with the Documentation and changed my function to the following.

from appwrite.client import Client from pydantic import BaseModel from datetime import datetime from typing import Optional from appwrite.services.tables_db import TablesDB from appwrite.query import Query import os

class Product(BaseModel): image: str description_de: str description_en: str description_fr: str price: float url: str visible: bool uvp: float name_en: str name_fr: str name_de: str popularity: int

def main(context): client = ( Client() .set_endpoint(os.environ["APPWRITE_FUNCTION_API_ENDPOINT"]) .set_project(os.environ["APPWRITE_FUNCTION_PROJECT_ID"]) .set_key(context.req.headers["x-appwrite-key"]) ) databases = TablesDB(client)

TypeScript
database_id = "67615fe8003a2b1eaebf"
products_id = "677ae7d9003770708d10"
body = context.req.body_json or {}
offset = int(body.get("offset", 0))

context.log(f"Offset from body: {offset}")
limit = 25
try:
    response = databases.list_rows(
        database_id=database_id,
        table_id=products_id,
        #model_type=Product,
        queries=[
            Query.equal("visible", True),
            Query.order_desc("$createdAt"),
            Query.limit(limit),
            Query.offset(offset)
        ]
    )
    context.log(response)
    data = response.model_dump()
    return context.res.json(data)

except Exception as e:
    return context.res.json({"error": str(e)}, 500)

Response But as you can see no real Data are in it. Even if i add them via Query.select Anyone can help me here?

TL;DR
Developers are reworking functions to use TablesDB list_rows method in Python. The code is querying data but not returning actual results even after using Query.select. A possible solution could be to ensure that the model type is properly defined and aligned with the table's structure to retrieve the necessary data fields.
Chefe#8332
18 Mar, 2026, 14:30

Query with Select response = databases.list_rows( database_id=database_id, table_id=products_id, model_type=Product, queries=[ Query.equal("visible", True), Query.order_desc("$createdAt"), Query.limit(limit), Query.offset(offset), Query.select([ "$id", "name_en", "name_fr", "name_de", "price", "url", "visible", "uvp", "popularity", "image", "description_de", "description_en", "description_fr"

TypeScript
                ])
        ]
    )
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more