Can't write to file in Google Cloud

Question:

Currently, I have an SQL Database that I wish to edit locally. This is for a flask app made in python 3, using sqlite3.

 con = sqlite3.connect('Database/accounts.db')
 cur = con.cursor()
 cur.execute(f"INSERT INTO Requests (Type, Argument, Priority, Time) VALUES ('{a}','{b}',{c},'{d}')")
 con.commit()

Except I keep getting the error: attempt to write a readonly database

Asked By: Yen

||

Answers:

The error says ‘readonly database’. Therefore it seems you don’t have write permission to this file. To fix this error, you can try the following:

  1. Check the file permissions: Make sure that the file has write
    permission for the user who is running the program. You can check
    the file permissions using the ls -l command in the terminal or
    command prompt.
  2. Change the file permissions: If the file does not have write
    permission, you can change the file permissions using the chmod
    command in the terminal or command prompt. For example, you can use
    chmod +w <filename> to add write permission to the file.
  3. Check the file path: Make sure that the file path you are using is
    correct and that the file exists at the specified location.
  4. Check if the file is open: If the file is open in another
    application or process, it may be locked and not allow writing. Make
    sure that the file is not open in any other application or process
    before trying to write to it.
  5. Try using a different file: If none of the above solutions work, you
    can try using a different SQLite database file or creating a new
    file with write permission and using that instead.
Answered By: Kabilesh

I found the answer because google cloud apps using Flask are forced to be a read-only database. Your forced to create files on anything but where those files are stored. For example cloud SQL or cloud storage

Answered By: Yen