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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.