-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Tue, 25 May 2004, Puneet Kishor wrote:
That is nice. I will definitely use this approach for myself. Many thanks for your helpful response.
Actually, based on some stuff in the digest that I hadn't seen before, I've made the code a little nicer:
# Get the table schema information my $query = "SELECT tbl_name,sql FROM sqlite_master WHERE sql NOT NULL"; my $sth = $dbh->prepare($query); $sth->execute; while ( my $row = $sth->fetchrow_hashref ) { print DUMPFILE "DROP TABLE $row->{tbl_name};\n"; my $schema = $row->{sql}; $schema =~ s/\n//g; print DUMPFILE "$schema;\n";
my $data_query = "SELECT * FROM $row->{tbl_name}";
my $data_sth = $dbh->prepare($data_query);
$data_sth->execute();
while ( my @row = $data_sth->fetchrow_array )
{
my @quoted;
print DUMPFILE "INSERT INTO $row->{tbl_name} VALUES (";
foreach my $item (@row)
{
push( @quoted, $dbh->quote($item) );
}
print DUMPFILE join( ",", @quoted ) . ");\n"; }
} -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD)
iD8DBQFAs3NTo4DwsyRGDscRApKGAKDnQXVmvNvquedpI8/0+Pg81gOs4wCfblTN 1IOdWCWdC6H9v2nW2+9vstc= =kCa2 -----END PGP SIGNATURE-----
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]