brwarn has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, While trying to figure out how DBI works for various things, I've attempted a simple call to delete all rows from a mysql table. I get no errors, but the rows aren't deleted either. What is it that I'm not understanding about DBI's usage?
my $dsn = "DBI:mysql:database=$db1;host=$host;port=$port"; my $dbh = DBI->connect($dsn, $user, $pw, { RaiseError => 1, AutoCommit => 0 }); # delete records from table rtemp my $sql = "delete from database.table"; my $sth = $dbh->prepare($sql); my $sth1 = $dbh->do($sql);

Replies are listed 'Best First'.
Re: DBI to delete rows
by velusamy (Monk) on Mar 05, 2009 at 04:30 UTC
    Hi,

    You didn't commit the database. So the changes didn't affect the table. Set AutoCommit value 1.

      That did the trick. Thank you!