Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Or… (credit to athomason's dump code)…… my $sth = $dbh->prepare("show tables") or &bail($DBI::errstr); my $rv = $sth->execute or &bail($DBI::errstr); while ( ( my $table_name ) = $sth->fetchrow_array ) { $sth2 = $dbh->prepare("describe $table_name") or die print "Can't do + select: $DBI::errstr"; $rv2 = $sth2->execute or die print "Can't execute the query: $DBI::e +rrstr"; while (($field_, $type_, $null_,$key_, $default_, $extra_) = $sth2-> +fetchrow_array) { #stuff with cols and then rows. } } …
DBD::Pg::db selectcol_arrayref failed: ERROR: Option 'tables' is not recognized.… # Get a list of the tables my @table_names; eval { @table_names = @{$dbh->selectcol_arrayref("SHOW TABLES")}; 1; } or die "Couldn't retrieve list of MySQL tables: $DBI::errstr"; # Get data from each table my (@tables, $table); eval { foreach $table (@table_names) { # Record how the table is layed out my $layout = $dbh->selectall_arrayref("DESCRIBE $table"); # Store the data in a 2D array reference my @fields = map ${$_}[0], @{$layout}; my $data = $dbh->selectall_arrayref("SELECT " . (join ',', @fields) . " FROM $table"); push @tables, [$layout, $data]; } 1; } or die "Failed while obtaining data from $table: $DBI::errstr"; …
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI - MySQL vs. PgSQL
by kschwab (Vicar) on Jan 17, 2002 at 06:58 UTC | |
|
Re: DBI - MySQL vs. PgSQL
by rdfield (Priest) on Jan 17, 2002 at 13:44 UTC | |
|
Re: DBI - MySQL vs. PgSQL
by quikwit (Beadle) on Jan 17, 2002 at 20:42 UTC | |
by xtype (Deacon) on Jan 19, 2002 at 03:05 UTC | |
|
Re: DBI - MySQL vs. PgSQL
by Anonymous Monk on Jan 18, 2002 at 16:06 UTC | |
by quikwit (Beadle) on Jan 18, 2002 at 19:01 UTC |