I am trying to print the column “question_column”
This is what Ive tried
my_list= app_tables.questions_choices.search(‘question_column’)
print(my_list)
This id the error I recieve
anvil.tables.TableError: Invalid argument to table query: “question_column”
if I enter
my_list= app_tables.questions_choices.search()[0][‘question_column’]
print(my_list)
I get the first row in the column but I’m trying to get all the rows in the column,Once that is sorted I will return the list in random order
First, it is a good idea to post your code using three back ticks above and below your code (```). That will help format it so it looks better on the forum.
To answer your question, could you try this query and see if it works for you?
my_list = app_tables.questions_choices.search()
print([x['question_column'] for x in my_list])
The way Anvil data tables work we need to get the full data table and then loop through the rows to only get the column we are interested in. Then we can print that.
I used a list comprehension above, but you could do a simple for loop with a print statement like this:
my_list = app_tables.questions_choices.search()
for row in my_list:
print(row['question_column'])