Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Dumper with DBI/DBD?

by kingram (Acolyte)
on Jul 30, 2012 at 08:45 UTC ( #984396=perlquestion: print w/ replies, xml ) Need Help??
kingram has asked for the wisdom of the Perl Monks concerning the following question:

When using DBI and the associated Database module, what is the best way to find out the final statement and contents reaching the database?

Particularly when you are passing values? E.G.
$sql="insert into test (one, two, three) VALUES (?,?,?)" @params = ('4','5',"str_to_date(\'$time_value\',\'%Y-%m-%d %h:%i:%s %p +\') $sth->prepare($sql); print Dumper($sth); my $rslt = $sth->execute($params[0],$params[1],$params[2]); print Dumper($rslt);
Dumper just gives me:
$VAR1 = bless( {}, 'DBI::st' );
$VAR1 = 1;
Not sure how to make sense of the first response, or if I need to use a different tool. The 2nd response indicates a successful SQL operation, but the date_to_string function is failing to put the date into the record.

Comment on Dumper with DBI/DBD?
Download Code
Re: Dumper with DBI/DBD?
by marto (Chancellor) on Jul 30, 2012 at 08:47 UTC

    If you're having problems debugging SQL/DBI I'd suggest using Tracing to try and find out where exactly the problem occurs, be it the query, DBI or the database drivers.

      That helped.
      DBI was doing it's job. The str_to_date function was being passed as a string instead of a function.
      I've learned quite a bit since I started building this thing.
      45 hours getting right with my Perl skills with a lot of good help from The Monks...

        I'm glad this helped, IMHO it's wise to familiarise yourself with debugging tools. An editor which supports Syntax_highlighting would also be advantageous.

Re: Dumper with DBI/DBD?
by mje (Deacon) on Jul 30, 2012 at 09:37 UTC

    You may find DBIx::Log4perl useful. It can log just the SQL and and bound parameters at execute time.

Re: Dumper with DBI/DBD?
by moritz (Cardinal) on Jul 30, 2012 at 10:04 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://984396]
Front-paged by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2014-07-29 02:36 GMT
Find Nodes?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:

    Results (211 votes), past polls