SQLite.pl
#!/usr/bin/perl -w
use strict;
use DBI;
my @r;
my $d=DBI->connect(qq(dbi:SQLite:dbname=@{[shift]}), q(), q());
my $s=$d->prepare_cached(join q(),<STDIN>);
$s->execute(@ARGV);
$,=qq(\t); $\=qq(\n);
print STDERR @{$s->{NAME}}; print @r while @r=$s->fetchrow_array;
$s->finish; $d->disconnect;
Do-SQLite-for.pl
#!/usr/bin/perl -w
use strict;
use DBI;
my $d=DBI->connect(qq(dbi:SQLite:dbname=@{[shift]}), q(), q());
my $s= $d->prepare_cached(do { open(SQL, q(<), shift); join(q(),<SQL>) });
$,=qq(\t); $\=qq(\n);
while(<>) {
chomp;
my @F = split(qq(\t), $_, -1);
$s->execute(@F);
}
$s->finish; $d->disconnect; close SQL;
没有评论:
发表评论