2016. 3. 6. 01:37
1. @ <- 배열에 넣는 방법;
이게 편함
#!/usr/bin/perl
use strict;
use DBI;
my $dbh = DBI->connect(
"dbi:SQLite:dbname=test.db",
"",
"",
{ RaiseError => 1 },
) or die $DBI::errstr;
my $sth = $dbh->prepare( "SELECT * FROM Cars LIMIT 5" );
$sth->execute();
my @row;
while (@row = $sth->fetchrow_array()) {
print "@row\n";
}
$sth->finish();
$dbh->disconnect();2. $에 넣어서 @$로 받는 방법
-> 테스트 하지 않음
#!/usr/bin/perl
use strict;
use DBI;
my $dbh = DBI->connect(
"dbi:SQLite:dbname=test.db",
"",
"",
{ RaiseError => 1 },
) or die $DBI::errstr;
my $sth = $dbh->prepare("SELECT * FROM Cars LIMIT 5");
$sth->execute();
my $row;
while ($row = $sth->fetchrow_arrayref()) {
print "@$row[0] @$row[1] @$row[2]\n";
}
$sth->finish();
$dbh->disconnect();'DB > sqlite' 카테고리의 다른 글
| [sqlite] DBI DBD on linux (0) | 2016.03.06 |
|---|---|
| [sqlite] rownum 기능 limit 기능으로 구한다. (0) | 2016.03.06 |
| [sqlite] perl 테이블 삭제/생성/인서트 (0) | 2016.03.06 |
| [sqlite] 테이블 구조 보기 (0) | 2016.03.06 |