#!/usr/bin/perl -w

# dump sql lite database

sub sqlite($$) {
	my ($db,$sql) = @_;
	open(my $s, qq{sqlite3 $db "$sql" |}) || die "can't open sqlite $db: $!";
	my $out;
	while(<$s>) {
		$out .= $_;
	}
	close($s);
	return $out;
}

my $db = shift @ARGV || die "usage: $0 sqlite3.db\n";

my $tables = sqlite($db, ".tables");
my $dump = sqlite($db, ".dump $tables");

print $dump;
