1

Recently, I have been trying to deploy an interactive Google App Engine that writes to a SQLite database, which works fine when running the app locally, but when running it through the server, I receive the error:

OperationalError: attempt to write a readonly database

I tried changing the permissions on my .db, .sql but no luck.

Any advice would be greatly appreciated.

2 Answers2

1

You can try changing permission of the directory and checking that .sqllite file exists and is writable

But generally speaking is not a good idea to rely on disk data when working on app engine as disk storage is ephemeral (unless you are using persistent disks on flex) but even then its better to use a cloud database solution

Andres S
  • 1,168
  • 7
  • 11
1

App Engine has exactly read-only file system, i.e. no files can be modified. It has, however, /tmp/ folder to store temporary files as the name suggests. It actually uses RAM, so not a good idea if the database is huge.

On app startup you can copy your original database file to /tmp/ folder and use it from there afterwards.

This works. However, all the changes in the database are lost when the app nodes scale to 0. Each node of the app has its own database copy and the data is not shared between the nodes. If you need the data to be shared between the app nodes, better use CloudSQL.

Fedor Petrov
  • 990
  • 9
  • 19