List_columns - cool feature, incorrect docs

I recently came across this line in the Anvil Docs (“Storing Data in Data Tables”):

You can list all the columns in a Data Table by calling list_columns() on the table object. This returns a list of strings.

a) Thank you! It’s very helpful.

b) Wish I’d known - I think I looked for a way to do this earlier searching on the old school name “fields” rather than “columns” Also, it’s a hidden feature within the app; if you type in: app_tables.my_table., the only methods that pop up are:

add_row
client_readable
client_writable
client_writable_cascade
get
get_by_id
has_row
search

c) docs are incorrect - it returns a list of dict, not a list of strings:

[{'name': 'Created', 'type': 'datetime'}, 
{'name': 'CreatedBy', 'type': 'liveObject'}, 
{'name': 'Description', 'type': 'string'}, 
{'name': 'Name', 'type': 'string'}, 
{'name': 'NumStudents', 'type': 'number'}, 
{'name': 'NumTeachers', 'type': 'number'}, 
{'name': 'Other', 'type': 'string'}, 
{'name': 'School', 'type': 'liveObject'}, 
{'name': 'Updated', 'type': 'datetime'}, 
{'name': 'UpdatedBy', 'type': 'liveObject'}]

I think it’s hidden by accident…
It’s probably missing from the autcomplete by mistake…
I only found this feature by accident on the forum.

1 Like