在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
文章来源:http://blog.sina.com.cn/s/blog_9d0445d50101czsr.html 首先需要用ppm安装DBI和DBD-mysql ,如果没有的话点击EDIT-preferences -repositories 下面的Suggested add就行了,你就可以找到更多的模块,就像ubuntu添加源一样 代码 use DBI; my $dbname = "数据库名"; my $location = "localhost"; my $database = "DBI:mysql:$dbname:$location"; my $db_user = "mysql用户名"; my $db_pass = "mysql密码"; my $dbh = DBI->connect($database,$db_user,$db_pass); my $sql = "SELECT * FROM gm_tf"; my $sth = $dbh->prepare($sql);#准备 $sth->execute() or die "无法执行SQL语句:$dbh->errstr"; #执行 while (@data = $sth->fetchrow_array()) {#fetchrow_array返回row print "Email:$data[0]\t Telephone:$data[1]\n"; } $sth->finish(); $dbh->disconnect;#断开数据库连接
|
请发表评论