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


Hi monks,
The folllowing script connects to a mysql db and generates a png graph.
When i run it i get the desired result but i also get the following error

Name "DBIx::Chart" used only once: possible typo at gp line 8.
DBI handle has uncleared implementors data at gp line 16.
DBI handle has uncleared implementors data at gp line 17.
dbih_clearcom (sth 0x851ac2c 0x8548e00, com 0x8548f10, imp DBD::mysql::st):
FLAGS 0x113: COMSET IMPSET Warn PrintError
PARENT DBIx::Chart::db=HASH(0x851ab00)
KIDS 0 (0 Active)
IMP_DATA undef
NUM_OF_FIELDS 3
NUM_OF_PARAMS 0
-> disconnect for DBD::mysql::db (DBIx::Chart::db=HASH(0x852b51c)~0x851ab00)
&imp_dbh->mysql: 852ba4c
<- disconnect= 1 at gp line 21
-> DESTROY for DBD::mysql::db (DBIx::Chart::db=HASH(0x851ab00)~INNER)
<- DESTROY= undef
SCHEMA +-----------+-------------+------+-----+------------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+------------+-------+ | ip | varchar(20) | | PRI | | | | interface | varchar(25) | | PRI | | | | ndate | date | | PRI | 0000-00-00 | | | ntime | time | | PRI | 00:00:00 | | | bin | int(11) | YES | | NULL | | | bout | int(11) | YES | | NULL | | +-----------+-------------+------+-----+------------+-------+ DATA ip int ndate ntime bin bout 10.151.1.254 fe0/1 2004-03-20 04:30:00 0 0 10.151.1.254 s0/1 2004-03-20 04:30:00 33 44 138.198.1.254 fe0/0 2004-03-20 04:30:00 455 455 #! /usr/bin/perl use strict; use warnings; use DBIx::Chart; my $db = "DBI:mysql:ndb"; my $dbh = DBIx::Chart->connect($db,'esm','esm') or die "Can't connect +to database: $DBIx::Chart->errstr!"; my $ip= $dbh->quote('xxx.xxx.xxx.xxx'); my $int = $dbh->quote('s0/0'); my $dt = $dbh->quote('2004-03-21'); my $sth = $dbh->selectrow_arrayref("SELECT ntime,bin,bout from bw_dail +y where ndate=".$dt." and ip=".$ip." and interface=".$int." RETURNING + LINEGRAPH(ntime,bin,bout) WHERE width=500 and height=250 and title=' +weekly bandwidth utilization graph' and colors in ('red','blue') and +background = 'lgray' and x-axis='time' and y-axis='bandwidth' and sig +nature='ESM\@ST' "); #$sth->bind_param(1,$dt); #$sth->execute; open(FI, ">gp1.png"); binmode FI; print FI $$sth[0]; close FI; $dbh->disconnect; exit 0;

1 .Do i need to explicitly close the statement handle? how do i get rid of the error
2. Code review? Can i use placeholders in selectrow_arrayref with RETURNING LINEGRAPH?
Thanks.
Regards,
chimni

Replies are listed 'Best First'.
Re: DBIx::Chart with mysql error: handle has uncleared implementors
by PodMaster (Abbot) on Mar 26, 2004 at 06:59 UTC
    I gave it a shot, I don't get that far :)(DBI 1.42, DBD::mysql 2.9003, DBIx::Chart 0.01, DBD::Chart 0.80)
    =begin sql use test; drop table bw_daily; create table bw_daily ( ip varchar(20) not null, interface varchar(25) not null, ndate date not null, ntime time not null, bin int(11), bout int(11), KEY(ip), KEY(interface), KEY(ndate), KEY(ntime) ); INSERT INTO bw_daily (ip, interface, ndate, ntime, bin, bout ) VALUES("10.151.1.254" , "fe0/1", "2004-03-20", "04:30:00", 0, 0); INSERT INTO bw_daily (ip, interface, ndate, ntime, bin, bout ) VALUES("10.151.1.254" , "s0/1" , "2004-03-20", "04:30:00", 33, 44); INSERT INTO bw_daily (ip, interface, ndate, ntime, bin, bout ) VALUES("138.198.1.254", "fe0/0", "2004-03-20", "04:30:00", 455, 455); =end sql =cut use strict; use warnings; use DBIx::Chart; my $db = "DBI:mysql:test"; my $dbh = DBIx::Chart->connect($db) or die "Can't connect to database: ",DBIx::Chart->errstr(); my $ip = $dbh->quote('xxx.xxx.xxx.xxx'); my $int = $dbh->quote('s0/0'); my $dt = $dbh->quote('2004-03-21'); my $sql = "SELECT ntime,bin,bout from bw_daily where ndate=" .$dt." and ip=" .$ip." and interface=" .$int." RETURNING LINEGRAPH(ntime,bin,bout) WHERE width=50 +0 and height=250 and title='weekly bandwidth utilization graph' and c +olors in ('red','blue') and background = 'lgray' and x-axis='time' an +d y-axis='bandwidth' and signature='ESM\@ST' "; my $sth = $dbh->selectrow_arrayref($sql); open(FI, ">gp1.png"); binmode FI; print FI $$sth[0]; close FI; $dbh->disconnect; exit 0; __END__ Can't take log of 0 at C:/Perl/site/lib/DBD/Chart/Plot.pm line 1556. DBI handle has uncleared implementors data. dbih_clearcom (sth 0x246510c, com 0x2461ba8, imp DBD::mysql::st): FLAGS 0x180113: COMSET IMPSET Warn PrintError PrintWarn PARENT DBIx::Chart::db=HASH(0x24659a4) KIDS 0 (0 Active) IMP_DATA undef NUM_OF_FIELDS 3 NUM_OF_PARAMS 0

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.