简体   繁体   English

用 perl 更新 sqlite 表

[英]update sqlite table with perl

i have the below perl code to update record on sqlite DB我有以下 perl 代码来更新 sqlite DB 上的记录

my $database = 'dbi:SQLite:dbname=my_db.db'; #

my $dbh = DBI->connect($database,"","",{AutoCommit => 1}) || die "Cannot  

connect: $DBI::errstr";



  my $sql = "update  my_table set table_id=51853 where table_id like '%49805%'";

  my $sth = $dbh->prepare( $sql );

 $sth->execute();


  $sth->finish;




   $dbh->disconnect();

it seems the code works but the update is not saved on the DB could someone help with this issue?似乎代码有效,但更新未保存在数据库中,有人可以帮助解决这个问题吗?

Check to see how many rows were updated.检查更新了多少 Log into the database and try this query to see how many rows would be affected:登录数据库并尝试此查询以查看会影响多少行:

SELECT COUNT(*) FROM my_table WHERE table_id LIKE '%49805%';

Also, make sure that you are using the correct database.此外,请确保您使用的是正确的数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM