2011年9月23日星期五

SQLite related 2 utilities, to fix the book & chapter names problems of Blackberry YouVersion bible reader

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;

Posted via email from purl's posterous

没有评论: