Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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.

      Thanks.
      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...
      Cheers!

        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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (16)
As of 2014-08-22 15:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (159 votes), past polls