http://www.perlmonks.org?node_id=1012670

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

So here is what i want to do: Monitor a bunch of tables in a MySQL database, append time stamps to WHEN the values changed, and then render the result in a graph.

1. Is there a tool/utility that somewhat does this already ( I could not find it ) 2. i used DBI, and was able to connect to the database and get some table column values:
#!/usr/bin/env perl use strict; use warnings; use Net::SSH::Perl; use DBI; my $database = 'co_sysdev'; my $server = 'devqa_dbm.corp'; my $user = 'username'; my $passwd = 'password'; my $row = ""; my $homologs = DBI->connect("dbi:mysql:database=co_sysdev;host=devqa_d +bm.corp;port=3310",'username','password'); # prepare an SQL statement #my $query_params = "select * from system_params"; # render the result in a graph format # save it locally in a csv format, to be used later for report my $query_coding_event = "select * from coding_event"; my $query_params = "select * from co_event"; #my $query = "select * from n_batch where status = 'started'"; #my $query = "select * from n_batch"; #my $query = "select id,customer_id,location_id,submitter,n_notes,hand +le from submission_batch where id is not null"; #my $query = "select id,customer_id,location_id,submitter,n_notes,hand +le from submission_batch where id is not null"; #my $query = "describe submission_batch"; #my $query = "show tables"; my $sql_params = $homologs->prepare($query_params); # execute an SQL statement $sql_params->execute(); # retrieve and print results while (my $row = $sql_params->fetchrow_arrayref) { #print join("\t", @$row), "\n"; print join(@$row), "\n"; print @$row . " \n"; } # Break connection with MySQL database $homologs->disconnect; exit;
This seems to be such a common use case, that i am surprised there arnt many scripts/packages available for the same.