1

I have the tutorial app from the flask docs and modified for my use.

I was able to deploy my flask app and create the db via container_commands (flask init-db)

But when I try to write something to the db from the web browser. It throws the exception that

"sqlite3.OperationalError: attempt to write a readonly database"

It seems the problem is the write permission to the sqlite file. But it was created at the time of deploying the application. Any help. Ideally when you are deploying in your own production env (not cloud), the sqlite is created in the venv/var/app-instance folder. How do I access this in AWS EB.

user3873617
  • 374
  • 1
  • 3
  • 15

1 Answers1

1

It looks like file write permission issue to me as well.

here is how i would troubleshoot the issue:

  • login to the instance via ssh, give permission to the file and see if it resolves the issue.
  • if it does resolves the issue, I would automate that using .ebextensions

Hope this helps you move forward.

Also look at the reference below shows how to change file permissions.

Reference: python sqlite3 OperationalError: attempt to write a readonly database

Arun Kamalanathan
  • 8,107
  • 4
  • 23
  • 39
  • Thank you. Though I gave full permission for the time being to both the instance folder and sqlite. I am not sure that's the best thing to do. But it will do for me for the time being. – user3873617 Jan 13 '20 at 04:01
  • glad to be of help, I agree with you, giving full permission is not a good idea. You should give write permission to the particular user (apache or wsgi user, i cant recall) . add it your backlog to fix it in the future . good luck – Arun Kamalanathan Jan 13 '20 at 04:07