in reply to Devel::Profiler and dprofpp Garbled profile
I have created a very small program that calls fetchrow_hashref using MySQL that gives dprofpp the heebie-geebies:
Can anyone else profile this ok? You just need to slot in your MYSQL db connection details, run the script and then run dprofpp in the same directory.#!/usr/local/bin/perl -w use strict; use DBI; use Devel::Profiler; sub logGeneral { print @_,"\n"; }; sub logFatal { logGeneral @_; die }; my $dbhost = 'localhost'; my $dbname = 'mydatabase'; my $dbuser = 'myuser'; my $dbpasswd = 'mypassword'; my $sql = 'select * from mytable'; my $dsn = "DBI:mysql:host=$dbhost;database=$dbname"; my $dbh = DBI->connect($dsn, $dbuser, $dbpasswd, { RaiseError => 0} ) or logFatal "DBI->Connect failed: DSN='$dsn' User='$dbuser' Error='$ +DBI::errstr'"; logGeneral "database opened"; my $sth = $dbh->prepare( $sql ) or logFatal("prepare failed: '$sql'\n ", $dbh->errstr); logGeneral "statement prepared"; my $result = $sth->execute() or logFatal("execute of '$sql' failed\n ", $dbh->errstr); logGeneral "statement executed: result $result"; my $row = $sth->fetchrow_hashref; logGeneral "row fetched:"; logFatal "no columns found" unless $sth->{NAME_lc}; for my $field ( @{$sth->{NAME_lc}} ) { logGeneral sprintf(" %-15s %s", $field, $row->{$field}); }
Thanks a bunch!
Jeff
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Devel::Profiler and dprofpp Garbled profile
by jaa (Friar) on Mar 26, 2004 at 09:55 UTC |