Attempt to write a readonly database

Web app being debugged on Window 11.

I keep getting this error when trying write or change anything in the sqlite database.

The file is not read only and it used to work.

Any ideas?

Where was and is now located the data base file ?

It’s on my computer and can clearly be read.

Maybe the File is locked because another Service/App/etc. is accessing it at the same time?

For example, if it is in a folder that is synchronized with a cloud, the synchronization service could access it and lock the file.

1 Like

Nope. Nothing like that. Thanks.

Have-you checked the hard disk with some utilities ?

Thats a bit vague. Where exactly? If it is eg. in the Applications folder then it can be read, but not written to because of macOS.
So make sure that the file AND the folder that it is in have read/write access for the user.

OP write he uses Windows 11.

Same there.

Please show the code and the full error message. A database doesn’t say “read-only” out of nothing.

Is the file is already open by another application / window (check code) and you attempt to open it a second time ?.

Nearly every time this crops up, it is because you are not acessing thedatabase you think you are using.
If you drag a database into the project, it will end up in something like a
program files/yourappname/yourappname resources folder
Anything inside program files sub folders will be considered as read-only by Windows

Your database should be placed in
specialfolder.applicationdata.child(“yourappname”) when the app starts up, if that file is not present
Then connect to that copy of the database
Don’t rely on the bundled database method (which seems like the simple way to do it when in the IDE.)

2 Likes

Windows computer. The database is in the same folder as the program.

This has worked for years.

I’ve gone in and made sure the folder is read/write.

I’ve had it give me the full native path after connecting. It is correct.

You mean when connecting. Not after.

Bad idea (in 2025) as already said earlier. The dslite file must bne located elsewhere
 as JKeff Tullin said some post earlier.

PS: this works when running in the IDE, but once you place your application oin Programs, the files are read only there (protected by the OS, Wundows 11 in your case / same apply for macOS).

No. Bad bad bad.
In debug mode, your app is not in ‘Program Files’, and a database next to it will probably be fine.

In a compiled app, if your app is on (say) a USB stick or network , it will probably be OK
But if its inside Program Files, the db will be read -only.

I’ve had it give me the full native path after connecting. It is correct

OK - what is it?

3 Likes

No the database is not in program files. My program and the database are in a documents folder and I am working in the IDE.

C:\Users\jvsca\OneDrive\Documents\GYMNASTICS\2024-2025\NCAA Challenge\challengeData.sqlite. This is the stupid onedrive folder on my hard drive, not the cloud.

Why would I store my program in C:\Program Files?

try to run in plane mode ? (WiFi OFF)

1 Like