On 4/18/08, Dennis Cote <[EMAIL PROTECTED]> wrote:
> P Kishor wrote:
>
> > I have a rather opaque application that is calling my db. Is there
> > something I can turn on in SQLite that will log all the statements
> > executed against it?
> >
> >
>
>  You can use sqlite3_trace() to register a callback that is passed each SQL
> statement as it is executed. Your callback can log this to a file. See
> http://www.sqlite.org/c3ref/profile.html for more info.
>
>  One drawback of this technique is that you don't get to see the values of
> any bound parameters.
>

Ok. Let's translate the above in English (for my sake).

Keep in mind the following as you answer the above -- I have SQLite
compiled already; I can recompile it. I have an application that I
can't change that is calling SQLite through its own interface. I want
to log whatever data requests are being made from my SQLite db. My
hunch is that recompiling SQLite won't help because this application
has its own SQLite driver.

Perhaps I can do the following -- create some kind of TRIGGER in my db
that automatically fires on every SELECT and logs every SELECT
statement in a table. Would that work? What would that TRIGGER look
like? Something like so --

CREATE TABLE foo (a, b);
CREATE VIEW view_bar AS
  SELECT a, b FROM foo;
CREATE TRIGGER log_foo
  INSTEAD OF SELECT ON view_bar
  INSERT INTO log_foo (<my application's select statement>);

CREATE TABLE log_foo (timestamp, action);

Would something like work, and if it will, what would it really look like?

I believe a while back, IIRC, someone (perhaps Richard himself) had
posted a way to log every action on a db in a table for posterity. I
can't find that right now, but that could work for me.





>  Dennis Cote
>


-- 
Puneet Kishor http://punkish.eidesis.org/
Nelson Institute for Environmental Studies http://www.nelson.wisc.edu/
Open Source Geospatial Foundation (OSGeo) http://www.osgeo.org/
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to