I'm working on an applciation that uses the DBI(v1.643) and DBD::SQLite(v1.66) Perl modules to interact with a database file and fetch some information. It does this by running SELECT queries using the prepare() and execute() methods. However, I get the following error when the database file isn't writable:
***DBD::SQLite::st execute failed: attempt to write a readonly database***
The error goes away when I make the file writable, but why is this restriction placed? Until now, the application was using DBD::SQlite version 1.13 and didn't need the file to be writable. I agree that for operations like INSERT etc. which would modify the database, it makes sense to have the file to be writable. However, fetching information using SELECT queries shouldn't ideally require the file to be writable.
I ran some tests and found that up to version 1.37 (DBD::SQLite), the SELECT queries work even when the file isn't writable.
Below is how I connect to the database file(which is read-only):
my $dbh = DBI->connect( 'dbi:SQLite:dbname=<fileName>', undef, undef,
{
RaiseError => 0,
AutoCommit => 0,
PrintError => 1
}
);
I would be grateful if someone helps me understand how to get around this :)