I was bumping against a row count quota and I was searching for the biggest violator.
From a Jupyter Notebook, I connected to my app using the uplink, and here is a snippet of code to get the row count for all the tables in your app.
import anvil.tables as tables
t_cache = tables.AppTables.cache
total_rows = 0
for table_name, table_ref in t_cache.items():
row_count = len(table_ref.search())
total_rows += row_count
print(f'{row_count:>10,} {table_name:s}')
print(f'\n\nTotal Rows in App: {total_rows:,}')
Here is the sample output:
55 user_services
67 user_org
91 sprint_card
32 content_emails
13 users
11 user_preferences
832 user_responses
96 user_notes
82 checkpoints
19 user_priority
Total Rows in App: 1,298
I discovered the AppTables.cache
by probing various classes in Anvil packages. Which is my way of saying, this solution has not been run by the the Anvil team, so in addition to hitting the database repeatedly in a loop, there might be other unintended consequences of using stuff that is not explicitly made public. So my recommendation is to tread lightly.
However, I was puzzled as to how I was exceeding the quota, and this snippet helped me hunt down the culprit.
Cheers,
Tyler