dsb has asked for the wisdom of the Perl Monks concerning the following question:

I have a text file parsing system which extracts data from content files and inserts that data into a MYSQL database. I wrote some of it, and some of it was already written when I started. There is a very high number of files from which this information comes from.

As of late the data in the database has been a little off. I want to somehow keep track of which parsing scripts are updating which database.tables during the parsing process. This process happens automatically of off a live data feed from the company which provides our content files.

What I'm asking is: Is there a way by which I can write a script which can monitor the database and when an INSERT/UPDATE/REPLACE query is run, this script finds the source of the query and logs it into a text file? I'd rather do this than add print statements and OUTPUT filehandles to every single one of the parsing scripts.

Thanks in advance for any suggestions. Please let me know if I'm not being clear on this.

Amel - f.k.a. - kel

Replies are listed 'Best First'.
(Ovid) Re: Database/Process Logging
by Ovid (Cardinal) on May 15, 2001 at 19:29 UTC

    You probably want to read this information about MySql's logs. Essentially, MySql will log this data for you and store the logs in the mysqld database directory. Your task, then, is simply to write a log processing script.

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Re: Database/Process Logging
by Masem (Monsignor) on May 15, 2001 at 19:32 UTC
    Mysql itself can nicely log all queries to a file, along with the connection number that was used. (The connection initiation is also logged). Thus, the only thing that you probably want to do is to have your script write out a bit to a text file to say what the file was, when the connection was made, and any other details that you want, so that you can use it to relate your scripts to the Mysql log.


    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain