Net::MySQL hangs
am 10.11.2007 01:09:02 von mmccawsStrange problem. I can get the example program to work with MySQL but
I can't get it to work with my other table. In hpux where would i
find the error messages generated by this?
Here is the code
$ cat dnssel.pl
#!/usr/bin/perl
# a test of querying the dnstable on database dev
use strict;
use Net::MySQL;
my $mysql = Net::MySQL->new(
hostname => 'localhost',
database => 'dev',
user => 'dev',
password => 'passwrd',
);
# now setup query into database
print " before if \n";
$mysql->query(q{SELECT hostid FROM dns_table});
print "aftere if \n";
# Iterate over each result printing out what we got.
my $record_set = $mysql->create_record_iterator;
while (my $record = $record_set->each) {
printf "hostid column: %s \n",
$record->[0];
}
$mysql->close;
and yet this works fine
#!/usr/bin/perl
# a test of querying the dnstable on database dev
use strict;
use Net::MySQL;
my $mysql = Net::MySQL->new(
hostname => 'localhost',
database => 'dev',
user => 'dev',
password => 'passwrd',
);
# now setup query into database
# INSERT example
=item comment
$mysql->query(q{
INSERT INTO test (first, next) VALUES ('Hello', 'World')
});
printf "Affected row: %d\n", $mysql->get_affected_rows_length;
=cut
# SLECT example
$mysql->query(q{SELECT * FROM test});
my $record_set = $mysql->create_record_iterator;
while (my $record = $record_set->each) {
printf "First column: %s Next column: %s\n",
$record->[0], $record->[1];
}
$mysql->close;
mysql> desc dnstable;
+--------------------+-----------------+--------+-------
+-------------------------------------+-------+
| Field | Type | Null | Key |
Default | Extra |
+-------------------+-----------------+--------+-------
+-------------------------------------+-------+
| hostid | varchar(4) | NO | PRI
| | |
| hostname | varchar(40) | NO | |
EMPTY | |
| current_ip | varchar(16) | NO | |
0.0.0.0 | |
| last_ip | varchar(16) | NO | |
0.0.0.0 | |
| num_change | tinyint(3) | NO |
| | |
| date_time | timestamp | NO | | CURRENT_TIMESTAMP
| |
+-------------------+-----------------+--------+-------
+-------------------------------------+-------+
6 rows in set (0.00 sec)
Oh yes there is one entry in this table.
This is on a HPUX 11i system.
Thanks
Mike