Insert data into table using Perl and MySQL

my $dbh= DBI->connect_cached( ’DBI:mysql: test’ ,
‘ username’ ,
‘ password’ ,
{ private_connection_key1 => ‘ connX’ })
my $sth= $dbh->prepare("insert into testtable values (1, ‘ first’ ) " )
or die " ERROR in prepare: " . $dbh->errstr . "\n";
my $rv= $sth->execute() ;
print "rows affected $rv\n" ;

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.