Obtaining the row or row-id of a just-added row

Hello Friends:

After adding a Data Table row, I need that row to populate a Linked column of a second table. So, I perform:

app_tables.my_table.add_row(**d)   # Returns nothing.
row = app_tables.my_table.get(**d) # I apply this soon after.

As far as I can tell, .add_row() doesn’t return anything helpful, like a reference to the added row or its row-id.

Is this how it’s done, or is there something a more efficient?

Thank you!

The add_row() returns the added row so you can get the row ID of any row by using

row_id = row.get_row_id()

4 Likes

Oh it does? Great. I didn’t see it in the doc-string or API so I came here to ask. Thank you for letting me know. :slight_smile:

1 Like

Second paragraph

3 Likes

Thank you. I had read that tutorial (when learning about Data Tables) but overlooked that statement (I hadn’t yet needed it). The pop-up docstring and API doc don’t specify what is returned.

The API docs show the return type clearly:

1 Like

I stand corrected. I looked exactly there and read the description, but didn’t notice the arrow. I just now re-visited the pop-up doc-string (in the Web IDE), and now I see it there as well. Thank you.