I keep an SQLite database in the application container, but only ever read from it. The application never, ever, writes to the database.
Is there a way to set the database so that it is read only?
Or should I simply put the database in the SpecialFolder.ApplicationData folder that I have for the application?
Afaik there is no way to open an SQLite database as read-only from xojo. If you sandbox your app you won’t be able to read from it as long as it resides inside of your app container. Copy it to applicationData, as you already mentioned.
That’s what I usually do.
If you want only YOUR applicatino to read it (and potentially write to it)
add an encryption key that only you app is aware of.
That way no external application will be able to alter it…
Another suggestion (if on OSX) is use CHMOD to set the permissions to read only (although those can be changed externally)
You can also set the OSX permissions to Locked to prevent any app from being able to write to it.
permissions can be changed with CHMOD and the lock can be removed with CHFLAG
not to mention both can be changed with “Get Info”
Thanks Oliver. I think I was resigned to doing that. Just hoped that it wasn’t necessary as the application only ever reads from the database.
Thanks Dave, Tim,
I only need to make the database read only. Perhaps I should be, but I’m not bothered about others monkeying with CHMOD etc.
Encrypt the database plus create INSERT and UPDATe triggers for all tables, which raise an exception.
[quote=280175:@Dave S]permissions can be changed with CHMOD and the lock can be removed with CHFLAG
not to mention both can be changed with “Get Info”[/quote]
You are correct. The locked flag is not meant to be a high-security system, it prevents accidental overwrite and delete. The way I interpreted the original request was not a high-security system.
Make it an in memory database?
Tim … wasn’t critisizing your suggestion… especially since it was in line with my own CHMOD one
My original suggestion of ecryption … plus I like Eli idea about triggers
Sometimes it helps to check how other application deals with what you want to do.
As far as I saw, one can open db from Xojo, Firefox, and probably many other applications. Now, reading the database does not means understanding the data base
and the op was about writing.
Xojo, Firefox apparently does not care about a user write in one of their data base; honestly, an end user is capable of anything, but is theres a chance (or a bad luck) one will wrote into your db file ?
Years ago Geoff did a blog http://www.realsoftwareblog.com/2011/04/buiding-demo-apps-using-in-memory.html which is what @Markus Winter is suggesting. The idea is that you don’t have a read only database, you just don’t write anything back to the disk.
There is an old request (and solution on how implement it)
Maybe is time to resume it!