Hello Michael,

Thanks for the quick response. Yes, I could add a field to put the source string in. But I would not like to bother applications with having to insert rows in the DML table. I would prefer that to happen automatically because I want to prevent entanglement of separate modules.

I have just read about the sqlite3_trace function. That might be what I am looking for, although it might be a tough job getting it to do what I want (with me not knowing C). For now I am not concerned yet with making it actually happen. My project is a pilot study. But I would like to make sure that it is really possible, i.e. that the building blocks are there. So I wonder if a hypothetical callback function that is registered with sqlite3_trace would have access to some kind of identifier of the program or process that has executed each SQL statement?

Regards,
Frans

On 2011-09-02 12:58, Black, Michael (IS) wrote:
If you can add a field that you can put a source string in you can do this:

create table dml (dmlstuff text, source text);
create trigger before insert on dml
for each row when new.source not like 'p2p'
begin
  select raise(rollback,'Not p2p source');
end;

sqlite>  insert into dml values('dml1','p2p');
sqlite>  select * from dml;
dml1|p2p
sqlite>  insert into dml values('dml2','other');
Error: Not p2p source
sqlite>  select * from dml;
dml1|p2p



Michael D. Black
Senior Scientist
NG Information Systems
Advanced Analytics Directorate




From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on 
behalf of Frans Knibbe [frans.kni...@geodan.nl]
Sent: Friday, September 02, 2011 4:21 AM
To: sqlite-users@sqlite.org
Subject: EXT :[sqlite] Track DML (from certain clients only)


Hello all,

I am trying to use SQLite as a data store for a P2P (peer to peer)
system. There could be several applications reading from and writing to
the database. One of these is the P2P module. It reads local additions
to the database (only INSERTs are allowed, rows are never DELETEd or
UPDATEd) and distributes to to other peers. The P2P module also insert
data it receives from other peers.

I would like to be able to distinguish data that has been written by the
P2P module from data that has been written by other local applications.
The latter data need to be handled by the P2P module, the former not
(otherwise the data would de replicated over and over again).

I thought I could make use of a table that stores all DML statements
from all applications except the P2P module. The P2P module could use
that table as a task list, and periodically check if there is any
unhandled DML in that table. All other applications could be made to
write their DML to that table, but that is not very elegant. I would
rather like this to be done automatically.

Is it possible to create a process (a trigger maybe) that monitors all
DML statements and writes them to a table, except when the statement is
issued by a specific application?

Or are there smarter ways of doing what I am trying to do?

Thanks in advance!

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


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

Reply via email to