Trying to display database data

Content Panel (or whatever your main container is)
└── data_grid_1
└── data_row_panel_1
├── label_id
├── label_priority
└── label_recall
I have my binds set correctly, when i run the app, the server code shows the correct data structure:
Fetched records: [{‘Recall ID’: 1, ‘Recall Priority’: ‘High’, ‘Recall’: ‘Flamable Shoes’}, {‘Recall ID’: 3, ‘Recall Priority’: ‘High’, ‘Recall’: ‘Flammable Socks’}] Fetched data: [{‘Recall ID’: 1, ‘Recall Priority’: ‘High’, ‘Recall’: ‘Flamable Shoes’}, {‘Recall ID’: 3, ‘Recall Priority’: ‘High’, ‘Recall’: ‘Flammable Socks’}] Data Grid items: [{‘Recall ID’: 1, ‘Recall Priority’: ‘High’, ‘Recall’: ‘Flamable Shoes’}, {‘Recall ID’: 3, ‘Recall Priority’: ‘High’, ‘Recall’: ‘Flammable Socks’}]

yet it just wont show on my app page

PLEASE HELP, need to get this done for a demo for a class and i am really struggling

Hello @marmaan, and welcome to the forum!

If you’ll post a clone link to your app-in-progress, someone may be able to help you out.

(Just saying “it isn’t working” doesn’t give enough information to eliminate any of the many, many ways that things might be going wrong.)

1 Like

sorry tom, I am still figuring out how to use anvil

Your issue is not with your data grid, but your data table and server code. In your data table you have a column named “Recall Priority”. Then in your server code you want to search on that column and use app_tables.high_priority_recalls.search(Recall Priority="High")

When you pass a keyword argument to a function in Python, there can’t be spaces as part of the argument name (spaces are not valid in Python variable names). Remove the space in your column name, so that it’s RecallPriority, and then fix up your conversion to a dictionary later.

You should have seen an error in the IDE console or in the app logs that would have pointed you to the search line being the problem.

1 Like

awesome thank you sir,

quick question, could you try to clone this version of the app,

I had my high priority tab working but now it gives me an initi error

When you’re getting errors like that, remove your own exception handling which obscures the stack trace. Without your own exception handling, you get a full stack trace in the IDE console, which shows:

TypeError: __init__() takes 2 positional arguments but 3 were given
at ServerModule1, line 24
called from HighPriorityRecalls, line 12
called from HighPriorityRecalls, line 16
called from Home, line 22

That tells you the problem is on line 24 of the server module, which is this line:

q.all_of(q.ilike("Recall Priority", "High"))

The error says you’re giving too many arguments to something. q.ilike takes only a single string, not two. You’re supposed to use the column name in front of it as a keyword argument, e.g. RecallPriority=q.ilike("High")

But it doesn’t make sense to use q.ilike unless you use a wildcard. And it doesn’t make sense to use q.all_of with a single option. So I’m not sure exactly what you’re trying to accomplish with that line.

3 Likes