Oh. You're right! :-) I did not understand you, but SQLite
apparently needs to write to the directory containing the database. I
> Actually, not to quibble, but you are incorrect, at least for all the
> Linux filesystems I use. What is usually needed is execute
> permissions on the directory, and write on the file.
> Proof:
> rcook@rzthriller1 (img_sqltrack): mkdir test
> rcook@rzthriller1 (img_sqltrack): touch test/file
> rcook@rzthriller1 (img_sqltrack): chmod 200 test/file
> rcook@rzthriller1 (img_sqltrack): ls -l test/file
> --w------- 1 rcook tools 0 Apr 4 15:47 test/file
> rcook@rzthriller1 (img_sqltrack): chmod 100 test
> rcook@rzthriller1 (img_sqltrack): ls -ld test
> d--x------ 2 rcook tools 4096 Apr 4 15:47 test
> rcook@rzthriller1 (img_sqltrack): echo hello > test/file
> generates no errors. File contains "hello"
> On Apr 4, 3:42 pm, Stephen Lombardo <sjlomba...@zetetic.net> wrote:
> > Hello,
> > Does bashtest have write access to the enclosing directory holding the
> > database file? If not, that is most likely the problem. Write access is
> > required to create the transaction journal file (or WAL file).
> > Cheers,
> > Stephen
> > On Wed, Apr 4, 2012 at 6:21 PM, wealthychef <rc...@llnl.gov> wrote:
> > > Hello, I must be missing something obvious here and am hoping someone
> > > can help me.
> > > I have a database: "/collab/usr/global/tools/IMG_private/img_sqltrack/
> > > Database.sqlite"
> > > I created it with user rcook.
> > > Executed the following commands:
> > > sqlite3_open(filename.c_str(), &database)
> > > sqlite3_key(database, key.c_str(), 7);
> > > "CREATE TABLE a (a INTEGER, b INTEGER);"
> > > "INSERT INTO a VALUES(1, 2);"
> > > "INSERT INTO a VALUES(5, 4);"
> > > I then set permissions to be 766, and confirmed that user "bashtest"
> > > can read and write to this file:
> > > hera553@bashtest:ls -l /collab/usr/global/tools/IMG_private/
> > > img_sqltrack/Database.sqlite
> > > -rwxrw-rw- 1 rcook tools 2048 Apr 4 15:07 /collab/usr/global/tools/
> > > IMG_private/img_sqltrack/Database.sqlite
> > > As rcook I can write to the database using the key "key" with the
> > > following command:
> > > rcook@rzthriller1 (img_sqltrack): /collab/usr/global/tools/IMG_private/
> > > chaos_4_x86_64/bin/sqlite3 /collab/usr/global/tools/IMG_private/
> > > img_sqltrack/Database.sqlite 'pragma key="key"; INSERT INTO a
> > > VALUES(1, 2);'
> > > But when user bashtest tries to write to the database I get a
> > > "readonly" error:
> > > hera553@bashtest:/collab/usr/global/tools/IMG_private/chaos_4_x86_64/
> > > bin/sqlite3 /collab/usr/global/tools/IMG_private/img_sqltrack/
> > > Database.sqlite 'pragma key="key"; INSERT INTO a VALUES(1, 2);'
> > > Error: attempt to write a readonly database
> > > What is going on here? Very mysterious. What barrier is bashtest
> > > running into? Help! :-)
> > > Thanks.