Seeking error definition

What I’m trying to do:
Can anyone provide details about the error:

TypeError: cannot concatenate ‘str’ and ‘LiveObjectProxy’ objects

What I’ve tried and what’s not working:

Code Sample:

# this is a formatted code snippet.
# paste your code between ``` 

Clone link:
share a copy of your app

Can you show the line with the error?

      result = alert(content="Hi " + row['FirstName'] + ", my name is " + name + ". " + app_tables.intro_message.search(tables.order_by("message"))[0],

Your final term gives you the first row of a table search. I suspect you probably want the content of some column within that row:

app_tables.intro_message.search(tables.order_by("message"))[0]["some_column_name"]
4 Likes

Am I perhaps looking in the wrong place in the documentation? In the Data Tables portion of the documentation it doesn’t show needing anything after “[0]”.

I was under the impression that where it says “tables.order_by(“message”)”, the “message” IS the column name, but that could just be a misunderstanding on my part:

My table name: intro_message
My column name: message

In the documentation (see picture):
Table name: people
Column name: Name

Do I need to list the column name twice?

@owen.campbell, I really appreciate your help on this. Thanks to your comments, I now have this working. Can I suggest a small tweak to the Docs? At the top of the Docs page, it shows only one import statement:

from anvil.tables import app_tables

But to get it working for me, it took a second import statement:

import anvil.tables as tables

It might be helpful for other users to include that line as well.

Thanks again,
Ryan


image
image

Without this import statement, it throws an error:
image

That’s because you’re using order_by from the tables module.

I just checked the order-by example in the docs. import anvil.tables as tables does not appear in that snippet, nor in any snippet above it.

To be fair, Anvil usually inserts that line by default into every module. But it also inserts from anvil.tables import app_tables, and yet that does appear in the snippets.

1 Like