dear monks,
#!"C:\perl\bin\perl.exe" -w
use strict;
use DBI();
use Data::Dumper;
my $database = "****";
my $hostname = "****";
my $port = "3306";
my $user = "****";
my $password = "****";
my $table = "****";
# connect
my $dbh = DBI->connect("DBI:mysql:database=$database;host=$hostname"
+,
"$user", "$password",
{'RaiseError' => 1});
my $scalar = '';
open( my $fh, "+>:scalar", \$scalar );
$dbh->trace( 1, $fh );
$dbh->do("INSERT INTO $table(version,filename,release_notes,rec_leve
+l,os_type) VALUES(1, 2, 3, 4, 5)");
# retrieve
my $sth = $dbh->prepare("SELECT * FROM $table");
$sth->execute();
while (my $ref = $sth->fetchrow_hashref()) {
print Dumper $ref; # output OK => gives a hash of one existing lin
+e
}
$sth->finish();
$dbh->disconnect();
print Dumper $scalar;
i try to import data to a mysql table. the $dbh->do("..") should do this but it wonīt. even if i dump $ref i get a line of the table, for this i suppose that there is a connection available.
show me the bug please...
perhaps there is a better way to do this?
EDIT
This IS a dump from the catched SQL line via this script. for that the connection is done. but the insert wonīt work.
EDIT
$VAR1 = {
'ID' => '2',
'date_compl_green' => undef,
'rec_level' => '1',
'feature_set' => undef,
'date_rec_green' => undef,
'size' => undef,
'os_type' => '1',
'remark' => undef,
'version' => '1.0',
'MD5_checksum' => undef,
'release_notes' => 'note',
'date_rec_yellow' => undef,
'date_compl_red' => undef,
'filename' => 'file',
'date_comp_yellow' => undef,
'date_rec_red' => undef
};
$perlig =~ s/pec/cep/g if 'errors expected';