How do I find the last record inserted?

Hmm, here are a few ways (there may be better solutions):

table_length=len(app_tables.my_table.search()) # does not load any rows
last_row=app_tables.my_table.search()[table_length-1]
last_row=list(app_tables.my_table.search())[-1] # casted to a list

I’m not 100% sure, but a row’s get_id() method, may always be incrementing, and if so, you could find the row with the largest row id. Although, the suggestions above seem better to me.

As I said, there may be better ways, but the top two seem to do the trick nicely.

1 Like