Search top 200 rows : anvil.server.SerializationError

I want to get the first 200 rows in the table but get this error
anvil.server.SerializationError: Cannot serialize return value from function.

Cannot serialize <class 'anvil._server.LiveObjectProxy.Iter'> object at msg['response'] at [Form1, line 49](javascript:void(0))

@anvil.server.callable
def get_all_rows():
  rows = app_tables.reading.search()[0:200]
  return rows

How can I get the result as a SearchIterator, not a list of dics?

From Anvil Docs | Using Data Tables from Python

The return value [from search()] is a SearchIterator , an iterator of Row objects.

So, if you eliminate the [0:200], it will return a SearchIterator. Then it is up to the caller to apply the [0:200], or whatever limits it actually needs.

1 Like

Thanks @p.colbert, I made it work in the client side