2011/6/30 Jean-Christophe Deschamps <j...@antichoc.net>

> >Is good enough for me. My only problem is that between reading the
> >data and
> >writing the changes, I want to be sure that no one  has changed the data.
> >For me that is enough.
>
> For this, a simple "Begin immediate;"  ...  "Commit;" embrassing you
> read-modify-write block will do.  Doesn't block readers and works in
> std and WAL journaling modes.
>

Do I understand it correctly that after a commit the database is writeable
again for others? In that case it is maybe better to do a:
    *PRAGMA locking_mode = EXCLUSIVE;
*followed by an update of the database. As long as the application is
running, I want to be sure that nobody writes to the database.*
*

I am now using:
            stat.execute("" +
                    "PRAGMA locking_mode = EXCLUSIVE;\n" +
                    "UPDATE authors\n" +
                    "SET    name = name\n" +
                    "WHERE  id = (\n" +
                    "    SELECT MIN(id)\n"+
                    "    FROM   authors\n" +
                    ");" +
                    "COMMIT;");

The COMMIT is to be sure that this will not unlock the database. It does
not. But I can read the database. Not a problem for me, but I understood it
should not be possible.

I just tried it with "BEGIN IMMEDIATE". Gives exactly the same results. So
properly I should stick to the "BEGIN IMMEDIATE"?

-- 
Cecil Westerhof
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to