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';

In reply to MySQL insert via DBI by AlexTape

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.