Saving results to load when app starts etc

Hi All.

I have a Key Module with 2 fields that are updated with the last run time and Last ID from two queries within the app.

I would like to store the last run value in the Key module so it always displays the last results as at the moment if I close the app, restart the on prem retool server or even open from another PC then it would start with a blank value.

Is there anyway to store the 2 values on the on prem retool postgress database or maybe a csv file somewhere on the server that can be updated with the latest last run values that can be updated and or loaded on app start etc?

Cheers

I think there could be a few ways of doing this.

  1. Whenever those queries are run, store the values in a table in teh retool db, and then run a query set to run on Page Load to retrieve those values.

  2. I think, if I understand you correctly, you might be asking for a listener event type function whereby upon window close store the two values?

Hi Scott

Option 1 sounds great.

Im basically querying 2 api's to show me the latest information.
I want the last transaction ID to be stored so that the next time the api query runs it only shows me the last set of transactions since the last run that was stored.

are there any guides on how to save the values to the retool database?

We are running on prem and found the database username and password in the .env file but was struggling to connect to it.

cheers

OK I am on cloud so I am not sure how the set up works on prem - that being said can't you simply upsert into a table with columns as needed?

Yup, just didn't want to have two instances of Postgres running in two docker containers on the one prem server running retool or start muddying other prod database's for the sake of storing and loading two fields 2 fields.

Even if there was a clean method to write the two values as a flat file such as csv in a folder on the retool server every time the value change so that it can always be called upon when the app first starts etc.

Was able to export the data using utils.exportData(mydata.data, "filename"); however that auto downloads to my local pc and have not seen a method to indicate a saving location or update file method sadly, unless I'm missing something.

The Retool Database queries should use PostgreSQL syntax. I also recommend this approach since you will need to have a resource - some api or db - in order to store any data. Another resource that wouldn't take too much time to set up is Google Sheets.

We have some documentation for connecting Retool Database on premise. You'll see that we do recommend externalizing the database