Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: MySQL insert via DBI

by graff (Chancellor)
on Sep 19, 2011 at 18:01 UTC ( #926785=note: print w/replies, xml ) Need Help??

in reply to MySQL insert via DBI

Have you tried using the "mysql" client utility to connect to the database (i.e. without using perl)? This would allow you to:
  • confirm that the username/password are correct
  • confirm that the table exists
  • confirm the names and data types of the columns in the table
  • see whether the insert statement you used in your perl script actually works when you run it at the 'mysql>' command line
  • see whether your perl script succeeded with its "insert" statement (and is only failing on the "select" statement)

Replies are listed 'Best First'.
Re^2: MySQL insert via DBI
by AlexTape (Monk) on Sep 20, 2011 at 08:34 UTC
    yes i tried. login correct. table exist. for the data, look at the dump => itīs a table line out of the DB. the scriptline actually works:
    mysql>insert into $table (version,filename,release_notes,rec_level,os_ +type) values ("1.0","1.txt","1.txt",3,4)\g
    there is no succeeded message given from perl. only the dump comes out of it.

    my $sth = $dbh->prepare("INSERT INTO $table(version,filename,release +_notes,rec_level,os_type) VALUES(?,?,?,?,?)"); $sth->execute( "test","test","test",1,1);
    $VAR1 = ' DBI::db=HASH(0x35bffc4) trace level set to 0x0/1 (DBI @ 0 +x0/0) in D BI 1.616-ithread (pid 2144) <- prepare(\'INSERT INTO table_1(version,filename,release _notes,rec_level,os_type) VALUES(?,?,?,?,?)\')= ( DBI::st=HASH(0x35ed6 +ec) ) [1 i tems] at line 21 <- execute(\'test\', \'test\', ...)= ( 1 ) [1 items] at lin +e 22 <- prepare(\'SELECT * FROM nl_firmware_recommendation\')= ( DBI::s +t=HASH(0x3 5d7bcc) ) [1 items] at line 24 <- execute= ( 2 ) [1 items] at line 25 !! ERROR: 2000 CLEARED by call to fetch method <- fetchrow_hashref= ( HASH(0x35f117c)16keys ) [1 items] row1 at s line 26 !! ERROR: 2000 CLEARED by call to fetch method !! ERROR: 2000 CLEARED by call to fetch method <- fetchrow_hashref= ( undef ) [1 items] row2 at line 26 <- finish= ( 1 ) [1 items] at line 29 <- disconnect= ( 1 ) [1 items] at line 30 ';
    this worked. but why $dbh->do is not able to do this?
    and whats about:     !! ERROR: 2000 CLEARED by call to fetch method?
    $perlig =~ s/pec/cep/g if 'errors expected';

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://926785]
[hippo]: Are you any good at perl?

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2018-06-23 09:12 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.