Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks

This may be quite a silly Question due to my lack of Windows Expertise. User 1 has created with my application a SQLite database and saved it in the Windows *ProgramData* Folder. User 1 can read and write the database without problems. If now User 2 uses the same Computer and logs in Windows, the same application of mine can NOT write in the same database and the following message is produced:

Tk::Error: DBD::SQLite::db do failed: attempt to write a readonly data +base at […]

The app did not create a "read only" database (user 1 has no problems writing to the database). This error occours even if User 1 has logged out from Windows.

There must be something I am not considering here…

Replies are listed 'Best First'.
Re: SQLite Windows readonl databasey
by Corion (Patriarch) on Aug 22, 2018 at 19:05 UTC

    If the file belongs to User 1, maybe User 1 did not grant "write" permissions to User 2?

    If you want a shared database (file), you need to make sure all users have the appropriate access permissions to that file.

      Thank you for the hint. I guess the problem has to do with Windows rights management of the ProgramData Folder. If I write the database in C:, for example, there is no problem for both users to access it. I find it a bit strange though as I thought the ProgramData folder should allow user independend savings of application data.

Re: SQLite Windows readonly database
by soonix (Chancellor) on Aug 23, 2018 at 08:40 UTC
    To extend Corion's hint: I'd look at the security settings of all three:
    1. Program Data folder
    2. subfolder(s) all the way down to the database file
    3. the database file itself
    and
    • compare the rights of both of these users
    • check who is the "owner"
Re: SQLite Windows readonl databasey
by thanos1983 (Parson) on Aug 23, 2018 at 08:20 UTC

    Hello Anonymous Monk,

    I was reading around on the Internet regarding your problem and one of the users says that he resolved it by removing the AutoCommit=>0 from the DBI->connect().

    Can you give it a try and let us know if it works for you? It can benefit other users on the future possibly.

    Looking forward to your update, BR.

    Seeking for Perl wisdom...on the process of learning...not there...yet!

      Thank you for your reply.

      After some experimenting, this is what I have noted:

      • Changing to AutoCommit=>0 does not solve the Problem, I still get the same error
      • I have now noted that the same error is given even if I try to read the database, for example with my $sth = $dbh->prepare("SELECT * FROM DatabaseInfo WHERE ID='1'");!!!

        Hello again Anonymous Monk,

        You need to remove it completely not set it to zero. As I said this is an assumption based on what I read.

        Hope this helps, BR.

        Seeking for Perl wisdom...on the process of learning...not there...yet!