Is there documentation/tutorial/video on creating a postgres based CRUD app?

I'm looking for a rapid web app building framework and based on some videos I watched Retool looked pretty good. Unfortunately, I'm having some issues finding documentation, and getting things to work when I do find some, or examples.

I have a simple scenario: one Postgres table ("Survey", created by importing a csv file); I have the data showing in a table successfully, have defined a primary key (id), have set specific columns to editable, now I want to implement persistence to the database.

I checked out this:

...but it seems to be for REST scenarios rather than postgres sql.

I watched this video:

...and made changes following that, but it seems to be a bit out of date, and even when making accommodations for what I think should make things work, whenever I change data and get the popup "Cancel/Save" button, pushing Save does nothing (the popup remains).

Is there a singular, all in one place document that explains all of the different options involved, or maybe different scenarios or approaches one may need to take for different scenarios?

Or at least, anything to point me in the right direction on this! :slightly_smiling_face:

Thank you...

Hi @trevorg - welcome to the forums!

Once you have import and parsed the CSV, did you send that data to the DB? If you are trying to just view the parsed data directly and make edits, there is nowhere for the data to be stored. Once you have send the parsed file data to the DB, it is available for you to query and display in a 'working' table with a "save" query that will persist your changes back to the DB.

Ya, it is ingested into a postgres table, and I can display it in a Table component, it is the write back of changes to the database that I cannot get working.

Does any explicit, straightforward documentation exist on this or do we have to kind of figure it out?

Yes - fancy new documentation update seems to have come through. I believe this has everything you need: Resource query tutorial | Retool Docs

1 Like

Well I tried that, I see that the table is refreshing or something (it kind of flashes), but the Cancel/Save button is still there, and the cell is still marked as edited.

This is pretty frustrating I have to say. If it was me and I'd gone through all the work to develop something as capable as this, I'd put 0.1% or so of that budget into developing some documentation on the most common scenarios people would want to accomplish.

UPDATE: I notice there is an error:

Update 2:
Changed "Array of records to update" from "surveysTable.changesetArray" (according to the documentation) to "{{surveysTable.changesetArray}}"

Now I get no error, but as soon as I tab off an edited cell, I get an infinite loop of refreshing of the table. It does seem like the data is being saved now though (even multiple edited rows!), but this refresh loop is a major problem.

I still have the red warning symbol on the updateUser query tab though.

Update 3:
I changed "Run Behavior" from Automatic to Manual, that seems to have changed the problem....now the flashing has stopped, but I get a "updateUser" popup in the lower right corner every time cell focus changes, regardless of editing.

Update 4:
Set both getSurveys and updateUser to automatic....now it seems like a refresh (or something) is happening every time cell focus changes, HOWEVER, the data seems to be getting saved to the database during all this.....BUT, the "edited" indicator remains on each edited cell, and the changes are happening without me pushing the save button, and the save button remains visible during all of this.

Update 5:
For fun I undid these 2 steps:
6. Configure the save action
7. Refresh data on save

Interestingly, my data still saves (though it isn't supposed to, according to the tooltip in the app). I still get a refresh when changing cell focus though.

Update 6:
I think I may have gotten it: I set Run Behavior on BOTH queries to Manual (this should really be documented), redid steps 6 & 7 above, and now it seems to be working as expected.

Something undesirable I noticed now though? If I edit a cell, then edit another cell but do not mouse or tab away to another cell and then press the Save button, the cell that was being edited reverts to its prior value and the change is lost. Is there any way to fix this, because I know this is going to cause problems in the real world.

Glad you got it working. Just curious, did you have an event handler in the cell instead of the table originally?

The undesirable behaviour you noted is also mentioned here Update table data does not pick up last value without "enter" key. You do need to "commit" the edit to the changeset by tab/enter/click somewhere else or it doesn't get picked up.

I think I might have accidentally had a row action at one point, but the ultimate root cause boiled down to setting Run Behavior to manual (I'd update the documentation to make this explicit).

Is it perhaps possible to inject some javascript to force the current edit to complete before the save happens? (I am having the same issue in Python Streamlit with AG Grid interestingly, and cannot figure out how to solve it.)