On 24 Nov 2016, at 11:02am, Florian Weimer <fwei...@redhat.com> wrote:

> The scenario is special in the follow way.  There is no database server, all 
> access goes directly to the database.  Unprivileged users without write 
> access to the RPM database are expected to run read-only queries against the 
> database.  Privileged users (basically, root) is expected to use locking to 
> exclude concurrent writers.  But read-only users should not be able to stop 
> acquisition of a write lock.
> 
> Is there a way to do this with SQLite?

From the above you would want to use WAL mode.  You can read about it here:

<https://www.sqlite.org/wal.html>

To put a database into WAL mode,

1) Open the database file.
2) If the database file is newly created (i.e. blank) Put at least one schema 
element into the file (e.g. create a TABLE).
3) Issue the command "PRAGMA journal_mode=WAL" in any program.  
4) Close the database file normally.

You can use the SQLite command-line tool to do the above if you wish, rather 
than having to write your own software to do it.  Once the database is set to 
this mode, that information is saved in the database file.  All connections 
which open it will automatically know it must be handled in WAL mode.

> One way that would work is to copy the database file after each modification 
> to a read-only public view.  But the database can be fairly large, so this 
> doesn't look feasible until we have reflink support at the file system level.

You should not have to worry about this level of things yourself.  The SQLite 
library handles this problem for you.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to