Files lost after reboot in Streamlit Cloud

Hi all!

Just to start with my problem in mind:

After my app on Streamlit Cloud reboots, data downloaded and files created on the run are lost.

I’m fairly new to SQL and databases in general and I’m building a CRUD streamlit app with SQLite.

The main ideia is that the user uploads some videos, the backend run some object detection and then persist the data collected from inference into a local SQLite database and download the videos (in the database the filepath is referenced in a videos table).

After the first video upload, two folder structures are created:

...
database/
└── my_sqlite.db (binaries)
videos/
└── video-<date_of_upload>-<user_name>.mp4
...

When my app go to sleep (to save resources) and then reboots, the database and videos are lost.

It is bad for the user, since their data that was on the cloud, now is lost.

[Questions]

  1. Is there some way to keep this data between reboots?
  2. Is this the best practice? Or should I do this with some online database service that when my app reboots, the data is kept and I just have to stablish the connection again?

Hey @solisoares,

Thanks for posting! Best practice in this case if you need to access the data again in the future would be to use a database – check out our guides on connecting to data sources here.

Thank you for your response, @Caroline!

I followed the link you provided, I think what you mean by “use a database” is to have a database up and running on a separeted server process acessible by a hostname (be it local in my machine, in a local server or in a hosted server like GCP), since my remote app uses SQLite (also a database, but not in a separeted server, therefore not keeping data after reboots). Am I right?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.