I have created a simple one column data base and am trying to display its contents in a text box
I get no text in the box when I open the form nut recieve a message <LiveObject: anvil.tables.Row> in the output
self.text_area_1.items = app_tables.questions.search()
for row in app_tables.questions.search():
print(row)
any ideas I’ve run out
ps.I’m new at this
Thanks Wayne Stokes
**Clone link:**
*share a copy of your app*
row
is the full row, potentially containing many columns.
<LiveObject: anvil.tables.Row>
is telling you that it’s a Row
object which may contain your data.
You can get your data by specifying the column name with row['column_name']
.
Oh, yeah, and welcome to the forum!
1 Like
Thanks a million for the reply !
I am still a little lost as to where to insert the [‘column_name’]
I tried at the print statement as well as like this
self.text_area_1.items = app_tables.questions[question_column].search()
there is only one column and six rows in the table.
The column name is question_column
I only inserted the for loop and print to try and figure out what was going wrong
this was all the code I thought I needed
self.text_area_1.items = app_tables.questions.search()
self.text_area_1.items = app_tables.questions[question_column].search()
for row in app_tables.questions.search():
print(row)
sorry to be a bother!
app_tables
is a software library.
app_tables.questions
is a table.
app_tables.questions.search
is a function that returns a (kinda) list of rows.
rows = app_tables.questions.search()
executes the function (because of the parentheses) and assigns the (kinda) list of rows to the variable rows
.
rows[0]
returns the first row in the list.
row = rows[0]
assigns the first row of rows
to the variable row
.
row['column_name']
returns the value of the column column_name
of row
.
You can do all in a less readable one liner: app_tables.questions.search()[0]['column_name']
.
You don’t use the property items
for the TextArea. You assign it to its text
property. Something like:
rows = app_tables.questions.search()
value = rows[0]['column_name']
self.text_area_1.text = value
5 Likes
Thank you very much Stefano.
Thats a great help.
Cheers Wayne