sqlite> .mode csv sqlite> .output hoge.csv
後は普通にselectを発行するとSTDOUTじゃなくてhoge.csvにデータが書き込まれる
他のmode等は.helpで確認可能.
sqlite> .mode csv sqlite> .output hoge.csv
use HTML::Template::Pro; use MyDB; # using DBIx::Skinny use Iterator::ToArray qw/to_array/; my $db = MyDB->new(...); my $iter = $db->search( 'hige_tbl', { length >= 30 } ); my @array = to_array $iter, sub { +{ id => $_->id, 'length' => $_->length } }; my $html = HTML::Template::Pro->new( filename => $file ); $html->param( hige_loop => \@array );
my @array; while ( defined ( my $row = $iter->next() ) { push @array, { id => $row->id, length => $row->length, }; }