Cecil,
>Do I understand it correctly that after a commit the database is writeable
>again for others?
Yes.
> 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.*
>*
If you _need_ exclusiveaccess all along, then start app, "begin
exclusive", do your stuf, "commit" and exit.
>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;");
A commit without begin * is useless and should result in an error being
returned.
But in the example above, there is asolutely no need for an explicit
transaction, nor any exclusive mode. Your UPDATE is an atomic
auto-commit operation in itself.
>The COMMIT is to be sure that this will not unlock the database.
Erroneous.
What I don't get is you later say it's a single-user, single-app
use. You don't have to take that much care in this case. Anyway,
enclosing R-M-W operations in an immediate (or exclusive) transaction
is always a good idea, should you have to introduce companion apps
later, or use a third-party DB manager in parallel.
--
<mailto:[email protected]>[email protected]
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users