Steve Palmer wrote: > I was going by the comment at http://www.sqlite.org/c_interface.html which > says: > > "If the file is read-only (due to permission bits or because it is located on > read-only media like a CD-ROM) then SQLite opens the database for reading > only." > > I don't know how true this is but I assume that since one of the error codes > is SQLITE_READONLY then it is probably accurate. In which case an extra > function that returns the state of the read-only flag would be nice. >
The information in c_interface.html is correct.
Adding a function to return the state of the "read-only flag" is not so simple, though, because there is not a single read-only flag. There is a separate read-only flag for each database.
Whenever you do an sqlite_open() you are really opening at least two database files - the one you named as an argument to sqlite_open() and a separate file used to store TEMP tables. It is quite possible for the main database to be read-only and the TEMP database to be read-write. You can also add additional files using the ATTACH command. Each such file can be either read-only or read-write. You can have up to 12 databases open all at once. Some can be read-only while others are read-write.
If you want to see if a particular table is read-only, try executing SQL like this:
UPDATE table SET rowid=0 WHERE 0;
If you get back an SQLITE_OK that means the table is read-write. If you get back SQLITE_READONLY that means the table is read-only. And because the WHERE clause is always false, nothing in the database will be changed.
-- D. Richard Hipp -- [EMAIL PROTECTED] -- 704.948.4565
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]