How to set up persistent SQLite3 file and logs file when deploying Python app to App Platform

hi guys! it is not a web framework, it is just bot that works in infinite loop and makes some requests on some API. in the course of doing work the app writes logs.txt in the root dir (where is). in the case of stopping app (SystemExit, KeyboardInterrupt) my app writes a small amount of data into SQLite3 file. in the case of any unexpected Exception it is doing the same as above and exiting. SQLite file is created in the root dir. The design is that the app has to be manually runnable and should not be automatically rerun if it fails and program exits. In this case I want to run the app by myself and the app is supposed to be reading the saved data from the SQlLite file. Resume:

  • SQLite file has to be preserved in case of app stopping/exiting and when I run the app again it is gonna read this db file (or I can delete this file)
  • logs.txt has to be preserved in case of app stopping/exiting (I need possibility investigate logs when the app is not running or I can delete logs)

thanks a lot for your help!

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
May 20, 2023
Accepted Answer

Hey Dennis 👋

I believe that we recently discussed this here:

In DigitalOcean’s App Platform, the filesystem is ephemeral, which means it doesn’t preserve files between deploys or application restarts, new deployments, and any container rebuilds. So, unfortunately, your logs and SQLite database would not persist if written to the local file system.

However, you can use other means to achieve persistence:

  1. For logs: You can configure your application to send logs to an external log management service like Papertrail, Datadog, and Logtail:

  2. For SQLite database: Instead of SQLite, you can use a database that supports persistence like PostgreSQL, MySQL, or MongoDB. You can host these databases on DigitalOcean’s Managed Databases, which offer automatic backups, failover, and other high availability features. If you wish to stick with SQLite, you could use an object storage service like DigitalOcean Spaces to store your SQLite file. However, you would need to manage uploading and downloading the file to Spaces when your application starts and stops, which can be a bit tricky.

An alternative option is to use a Droplet instead, that way you will be able to store both your SQLite and your logs on the Droplet without having to worry for the ephemeral storage on the App Platform:



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel