Perl script to pull SQL statements from CommLog - Mailing list pgsql-odbc

From David Gardner
Subject Perl script to pull SQL statements from CommLog
Date
Msg-id C975BFE03CC5DE4999143A5BEA9FB515021E46B3FB@yucex.lax.yucwin
Whole thread Raw
List pgsql-odbc
Thought this might be usefull to others. Every once and a while I start wondering what MS Access is doing to my
queries,and want to get an idea if the client app is actually using my indexes. I wrote a little Perl script to extract
theSQL statements from the CommLog output to make it easy for me to copy-paste statements into pgAdmin3.  It takes the
logfile in as a command line parameter, and spits the SQL statements to standard out, so running it looks like this: 
getSQLfromLog.pl psqlodbc_4364.log > output2.sql

Feel free to use/modify whatever. I'm not much of a Perl guy, so I won't be offended if you point out any errors/bugs.

---
David Gardner, IT
The Yucaipa Companies
(310) 228-2855


---------------------------  getSQLfromLog.pl ---------------------
#! /usr/bin/perl
# Author: David Gardner davidgardner28@gmail.com

if ($#ARGV == -1 ) {
  print ("Usage: getSQLfromLog.pl <source file>\n") and die;
} else {
  $fileName = $ARGV[0];
  open (SOURCE, $fileName) or die "Failed to open $fileName";
}

for $line (<SOURCE>) {
  if ($line =~ /query='/) {
    @fields = split(',', $line, 2);
    $query = $fields [1];
    $query =~ s/\ query='//ig;
    $query =~ s/'$//ig;
    print "$query";
  }
}

close SOURCE;

pgsql-odbc by date:

Previous
From: David Gardner
Date:
Subject: Re: Problems accesing exported MsAccess data
Next
From: Hiroshi Inoue
Date:
Subject: Re: [psqlODBC 08.02.0402] OpenSSL libraries