ITPub博客

首页 > 数据库 > 数据库开发技术 > Perl访问DBI

Perl访问DBI

原创 数据库开发技术 作者:longer3281 时间:2014-02-24 10:46:33 0 删除 编辑
以下脚本可以循环读取数据库的tr表中的记录。 
#!/usr/bin/perl
use strict;
use DBI;
my $dsn="DBI:mysql:demo:localhost:3306";
my $user="root";
my $passwd="mysql56";
my $dbh = DBI->connect($dsn, $user, $passwd);

my $sth = $dbh->prepare("select * from tr where id <50 order by 1 desc");
$sth->execute();
my @arr;
while(@arr = $sth->fetchrow_array()){
   print join("|", @arr),"\n";
}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9606353/viewspace-1086743/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: MySQL触发器
下一篇: mysql show命令
请登录后发表评论 登录
全部评论
数据库架构师,DB从业经历 DB2,Oracle,MySQL,PGSQL,MonogDB 等数据库,hadoop,hive,spark,flink,doris等大数据技术。

注册时间:2009-05-22

  • 博文量
    69
  • 访问量
    185398