From: <rv...@us...> - 2009-06-11 02:11:09
|
Revision: 20 http://treebase.svn.sourceforge.net/treebase/?rev=20&view=rev Author: rvos Date: 2009-06-11 02:10:55 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Added clarifying comments on sqldump script. Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 01:37:41 UTC (rev 19) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 02:10:55 UTC (rev 20) @@ -4,6 +4,10 @@ use CIPRES::TreeBase::RecDumper; use Getopt::Std; +# required environment variables: +# TREEBASE_DB_USER=*** +# TREEBASE_DB_PASS=*** +# TREEBASE_DB_DSN=*** my %opt = ( 'x' => 0 ); getopts('x', \%opt) or usage(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 04:02:18
|
Revision: 19 http://treebase.svn.sourceforge.net/treebase/?rev=19&view=rev Author: rvos Date: 2009-06-11 01:37:41 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Added clarifying comments on sqldump script. Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-05-29 22:52:00 UTC (rev 18) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 01:37:41 UTC (rev 19) @@ -1,58 +1,87 @@ #!/usr/bin/perl -use CIPRES::TreeBase::DBIUtil qw(get_colnames get_coltypes); +use CIPRES::TreeBase::DBIUtil; use CIPRES::TreeBase::RecDumper; use Getopt::Std; -my %opt = ('x' => 0); +my %opt = ( 'x' => 0 ); getopts('x', \%opt) or usage(); +# database table to dump out, provided as command line argument my $table = shift || usage(); + +# output file handle, by default to STDOUT, or... my $ofh = \*STDOUT; -if (@ARGV) { + +# ...second command line argument is file name... +if ( @ARGV ) { my $ofile = shift; + + # ...try to open a write handle to it... open my($fh), ">", $ofile or die "Couldn't write output file '$ofile': $!; aborting"; + + # ...and use that... $ofh = $fh; } +# create database handle my $dbh = CIPRES::TreeBase::DBIUtil->dbh or die "Couldn't connect to database: " . DBI->errstr; -$dbh->{RaiseError} = 1; +$dbh->{'RaiseError'} = 1; { - my @names = get_colnames($dbh, $table); - my @types = get_coltypes($dbh, $table); - my $dumper = - CIPRES::TreeBase::RecDumper->new( - FIELDS => \@names, - TYPES => \@types, - TABLE => $table - ) or die "??"; + # only using these two functions once, so for clarity as to where they + # originate let's use the fully qualified names. + my @names = CIPRES::TreeBase::DBIUtil::get_colnames($dbh, $table); + my @types = CIPRES::TreeBase::DBIUtil::get_coltypes($dbh, $table); + + # instantiate a RecDumper object, which will format a row-as-array + # into an insert statement + my $dumper = CIPRES::TreeBase::RecDumper->new( + 'FIELDS' => \@names, + 'TYPES' => \@types, + 'TABLE' => $table + ) or die "Couldn't instantiate CIPRES::TreeBase::RecDumper"; + + # give dumper the output handle to write to, i.e. either STDOUT + # or a file specified on the command line $dumper->set_output($ofh); { - my $q = qq{select * from $table}; - my $sth = $dbh->prepare($q); - $sth->execute(); - - my $row; - if ($opt{x}) { - my $count = 0; - while ($row = $sth->fetchrow_arrayref) { - ++$count; - $dumper->rec(@$row); - print STDERR "\r$count" if $count % 1000 == 0; - } - } else { - $dumper->rec(@$row) while $row = $sth->fetchrow_arrayref; - } - - $sth->finish(); - print STDERR "\n" if $opt{x}; + # get all rows from $table + my $q = qq{select * from $table}; + my $sth = $dbh->prepare($q); + $sth->execute(); + + my $row; + + # if -x is provided, print out progress counter + if ( $opt{'x'} ) { + my $count = 0; + while ( $row = $sth->fetchrow_arrayref ) { + ++$count; + $dumper->rec(@$row); + print STDERR "\r$count" if $count % 1000 == 0; + } + } + + # without -x just dump the records + else { + while ( $row = $sth->fetchrow_arrayref ) { + $dumper->rec(@$row); + } + } + + # finish the statement handler + $sth->finish(); + + # add line break if we're printing a progress counter + print STDERR "\n" if $opt{'x'}; } } +# disconnect from database $dbh->disconnect; exit 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 05:46:36
|
Revision: 22 http://treebase.svn.sourceforge.net/treebase/?rev=22&view=rev Author: rvos Date: 2009-06-11 05:46:05 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Changed arg handling to use Getopt::Long Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 04:02:05 UTC (rev 21) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 05:46:05 UTC (rev 22) @@ -2,39 +2,37 @@ use CIPRES::TreeBase::DBIUtil; use CIPRES::TreeBase::RecDumper; -use Getopt::Std; +use Getopt::Long; +use Pod::Usage; +use strict; -# required environment variables: -# TREEBASE_DB_USER=*** -# TREEBASE_DB_PASS=*** -# TREEBASE_DB_DSN=*** -my %opt = ( 'x' => 0 ); -getopts('x', \%opt) or usage(); +my @tables; # database table to dump out +my $outhandle = \*STDOUT; # handle to write dump to +my $with_progress_meter = 0; # switch to print a progress meter +my $with_inserts = 1; # write insert statements +my $with_creates = 0; # write create statements -# database table to dump out, provided as command line argument -my $table = shift || usage(); +GetOptions( + 'creates!' => \$with_creates, + 'inserts!' => \$with_inserts, + 'progress!' => \$with_progress_meter, + 'user=s' => \$ENV{'TREEBASE_DB_USER'}, + 'pass=s' => \$ENV{'TREEBASE_DB_PASS'}, + 'dsn=s' => \$ENV{'TREEBASE_DB_DSN'}, + 'table=s' => \@tables, + 'all' => sub { @tables = get_all_tables() }, + 'file=s' => sub { + my $file = pop; + open my $fh, '>', $file + or die "Couldn't write output file '$file': $!; aborting"; + $outhandle = $fh; + }, +) || pod2usage(); -# output file handle, by default to STDOUT, or... -my $ofh = \*STDOUT; - -# ...second command line argument is file name... -if ( @ARGV ) { - my $ofile = shift; - - # ...try to open a write handle to it... - open my($fh), ">", $ofile - or die "Couldn't write output file '$ofile': $!; aborting"; - - # ...and use that... - $ofh = $fh; -} - # create database handle -my $dbh = CIPRES::TreeBase::DBIUtil->dbh - or die "Couldn't connect to database: " . DBI->errstr; -$dbh->{'RaiseError'} = 1; +my $dbh = get_handle(); -{ +for my $table ( @tables ) { # only using these two functions once, so for clarity as to where they # originate let's use the fully qualified names. my @names = CIPRES::TreeBase::DBIUtil::get_colnames($dbh, $table); @@ -50,9 +48,13 @@ # give dumper the output handle to write to, i.e. either STDOUT # or a file specified on the command line - $dumper->set_output($ofh); + $dumper->set_output($outhandle); - { + if ( $with_creates ) { + + } + + if ( $with_inserts ) { # get all rows from $table my $q = qq{select * from $table}; my $sth = $dbh->prepare($q); @@ -60,8 +62,8 @@ my $row; - # if -x is provided, print out progress counter - if ( $opt{'x'} ) { + # if --progress is provided, print out progress counter + if ( $with_progress_meter ) { my $count = 0; while ( $row = $sth->fetchrow_arrayref ) { ++$count; @@ -70,7 +72,7 @@ } } - # without -x just dump the records + # if --noprogress or default, just dump the records else { while ( $row = $sth->fetchrow_arrayref ) { $dumper->rec(@$row); @@ -81,7 +83,7 @@ $sth->finish(); # add line break if we're printing a progress counter - print STDERR "\n" if $opt{'x'}; + print STDERR "\n" if $with_progress_meter; } } @@ -93,3 +95,14 @@ print "$0 table-name [output_filename]\n"; exit 1; } + +sub get_all_tables { + +} + +sub get_handle { + my $dbh = CIPRES::TreeBase::DBIUtil->dbh + or die "Couldn't connect to database: " . DBI->errstr; + $dbh->{'RaiseError'} = 1; + return $dbh; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 06:01:49
|
Revision: 23 http://treebase.svn.sourceforge.net/treebase/?rev=23&view=rev Author: rvos Date: 2009-06-11 06:01:41 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Added comments and pod2usage calls Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 05:46:05 UTC (rev 22) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:01:41 UTC (rev 23) @@ -12,6 +12,7 @@ my $with_inserts = 1; # write insert statements my $with_creates = 0; # write create statements +# get command line options, see Getopt::Long GetOptions( 'creates!' => \$with_creates, 'inserts!' => \$with_inserts, @@ -20,15 +21,35 @@ 'pass=s' => \$ENV{'TREEBASE_DB_PASS'}, 'dsn=s' => \$ENV{'TREEBASE_DB_DSN'}, 'table=s' => \@tables, + 'help|?' => sub { pod2usage( '-verbose' => 0 ) }, # see Pod::Usage + 'man' => sub { pod2usage( '-verbose' => 1 ) }, # see Pod::Usage 'all' => sub { @tables = get_all_tables() }, 'file=s' => sub { my $file = pop; open my $fh, '>', $file - or die "Couldn't write output file '$file': $!; aborting"; + or pod2usage( + '-msg' => "Couldn't write output file '$file': $!; aborting", + '-verbose' => 0, + '-exitval' => 1 + ); # see Pod::Usage $outhandle = $fh; }, -) || pod2usage(); +) || pod2usage( '-verbose' => 0, '-exitval' => 1 ); +# need at least one table, see Pod::Usage +pod2usage( + '-verbose' => 0, + '-exitval' => 1, + '-msg' => 'Need at least one table to dump, aborting' +) unless @tables; + +# need at least one action, see Pod::Usage +pod2usage( + '-verbose' => 0, + '-exitval' => 1, + '-msg' => 'Need at least one operation to write out (--inserts and/or --creates), aborting' +) unless $with_creates or $with_inserts; + # create database handle my $dbh = get_handle(); @@ -91,11 +112,6 @@ $dbh->disconnect; exit 0; -sub usage { - print "$0 table-name [output_filename]\n"; - exit 1; -} - sub get_all_tables { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 06:10:10
|
Revision: 24 http://treebase.svn.sourceforge.net/treebase/?rev=24&view=rev Author: rvos Date: 2009-06-11 06:10:07 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Partially implemented get_all_tables() Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:01:41 UTC (rev 23) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:10:07 UTC (rev 24) @@ -113,7 +113,14 @@ exit 0; sub get_all_tables { - + my $dbh = get_handle(); + my $sth = $dbh->preparse('show tables'); + #my @fetched_tables; + use Data::Dumper; + $sth->execute(); + while ( my $row = $sth->fetchrow_arrayref ) { + warn Dumper($row); + } } sub get_handle { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 06:11:19
|
Revision: 25 http://treebase.svn.sourceforge.net/treebase/?rev=25&view=rev Author: rvos Date: 2009-06-11 06:11:11 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Fixed typo (prepare, not preparse) Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:10:07 UTC (rev 24) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:11:11 UTC (rev 25) @@ -114,7 +114,7 @@ sub get_all_tables { my $dbh = get_handle(); - my $sth = $dbh->preparse('show tables'); + my $sth = $dbh->prepare('show tables'); #my @fetched_tables; use Data::Dumper; $sth->execute(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 06:19:37
|
Revision: 26 http://treebase.svn.sourceforge.net/treebase/?rev=26&view=rev Author: rvos Date: 2009-06-11 06:19:36 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Changed SQL for fetching all tables Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:11:11 UTC (rev 25) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:19:36 UTC (rev 26) @@ -114,7 +114,7 @@ sub get_all_tables { my $dbh = get_handle(); - my $sth = $dbh->prepare('show tables'); + my $sth = $dbh->prepare('SELECT * FROM SYSCAT.TABLES'); #my @fetched_tables; use Data::Dumper; $sth->execute(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 06:20:48
|
Revision: 27 http://treebase.svn.sourceforge.net/treebase/?rev=27&view=rev Author: rvos Date: 2009-06-11 06:20:46 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Changed return type to hashref Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:19:36 UTC (rev 26) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:20:46 UTC (rev 27) @@ -118,7 +118,7 @@ #my @fetched_tables; use Data::Dumper; $sth->execute(); - while ( my $row = $sth->fetchrow_arrayref ) { + while ( my $row = $sth->fetchrow_hashref ) { warn Dumper($row); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 06:30:53
|
Revision: 28 http://treebase.svn.sourceforge.net/treebase/?rev=28&view=rev Author: rvos Date: 2009-06-11 06:30:51 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Added --name-file-after-table command line switch Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:20:46 UTC (rev 27) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:30:51 UTC (rev 28) @@ -7,13 +7,15 @@ use strict; my @tables; # database table to dump out -my $outhandle = \*STDOUT; # handle to write dump to -my $with_progress_meter = 0; # switch to print a progress meter -my $with_inserts = 1; # write insert statements -my $with_creates = 0; # write create statements +my $outhandle = \*STDOUT; # handle to write dump to +my $with_progress_meter = 0; # switch to print a progress meter +my $with_inserts = 1; # write insert statements +my $with_creates = 0; # write create statements +my $name_file_after_table = 0; # name output file after table # get command line options, see Getopt::Long GetOptions( + 'name-after-table' => \$name_file_after_table, 'creates!' => \$with_creates, 'inserts!' => \$with_inserts, 'progress!' => \$with_progress_meter, @@ -33,7 +35,7 @@ '-exitval' => 1 ); # see Pod::Usage $outhandle = $fh; - }, + }, ) || pod2usage( '-verbose' => 0, '-exitval' => 1 ); # need at least one table, see Pod::Usage @@ -67,8 +69,13 @@ 'TABLE' => $table ) or die "Couldn't instantiate CIPRES::TreeBase::RecDumper"; - # give dumper the output handle to write to, i.e. either STDOUT - # or a file specified on the command line + # give dumper the output handle to write to, i.e. either STDOUT, + # or a file specified on the command line, or the table name + if ( $name_file_after_table ) { + close $outhandle; + open my $fh, '>', "${table}.sql" or die $!; + $outhandle = $fh; + } $dumper->set_output($outhandle); if ( $with_creates ) { @@ -115,12 +122,11 @@ sub get_all_tables { my $dbh = get_handle(); my $sth = $dbh->prepare('SELECT * FROM SYSCAT.TABLES'); - #my @fetched_tables; + my @fetched_tables; use Data::Dumper; $sth->execute(); - while ( my $row = $sth->fetchrow_hashref ) { - warn Dumper($row); - } + push @fetched_tables, $_->{'TABNAME'} while ( $sth->fetchrow_hashref ); + warn Dumper(\@fetched_tables); } sub get_handle { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 06:32:50
|
Revision: 29 http://treebase.svn.sourceforge.net/treebase/?rev=29&view=rev Author: rvos Date: 2009-06-11 06:32:49 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Changed fetchrow_hashref processing. Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:30:51 UTC (rev 28) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:32:49 UTC (rev 29) @@ -125,7 +125,10 @@ my @fetched_tables; use Data::Dumper; $sth->execute(); - push @fetched_tables, $_->{'TABNAME'} while ( $sth->fetchrow_hashref ); + while ( my $row = $sth->fetchrow_hashref ) { + push @fetched_tables, $row->{'TABNAME'}; + warn Dumper($row); + } warn Dumper(\@fetched_tables); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 06:40:38
|
Revision: 30 http://treebase.svn.sourceforge.net/treebase/?rev=30&view=rev Author: rvos Date: 2009-06-11 06:40:36 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Added check to make sure we're reading the right table type. Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:32:49 UTC (rev 29) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:40:36 UTC (rev 30) @@ -79,7 +79,7 @@ $dumper->set_output($outhandle); if ( $with_creates ) { - + print $outhandle "CREATE TABLE $table;\n"; } if ( $with_inserts ) { @@ -127,9 +127,10 @@ $sth->execute(); while ( my $row = $sth->fetchrow_hashref ) { push @fetched_tables, $row->{'TABNAME'}; - warn Dumper($row); + warn Dumper($row) if $row->{'TABNAME'} eq 'XMLOBJECTS'; } - warn Dumper(\@fetched_tables); + #warn Dumper(\@fetched_tables); + return @fetched_tables; } sub get_handle { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 06:42:49
|
Revision: 31 http://treebase.svn.sourceforge.net/treebase/?rev=31&view=rev Author: rvos Date: 2009-06-11 06:42:46 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Added check to make sure we're reading the right table type. Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:40:36 UTC (rev 30) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:42:46 UTC (rev 31) @@ -126,10 +126,14 @@ use Data::Dumper; $sth->execute(); while ( my $row = $sth->fetchrow_hashref ) { - push @fetched_tables, $row->{'TABNAME'}; - warn Dumper($row) if $row->{'TABNAME'} eq 'XMLOBJECTS'; + if ( $row->{'DEFINER'} eq 'JRUAN' ) { + push @fetched_tables, $row->{'TABNAME'}; + } + else { + warn $row->{'TABNAME'}; + } } - #warn Dumper(\@fetched_tables); + warn Dumper(\@fetched_tables); return @fetched_tables; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 06:45:31
|
Revision: 32 http://treebase.svn.sourceforge.net/treebase/?rev=32&view=rev Author: rvos Date: 2009-06-11 06:45:25 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Changed fetchrow_hashref processing. Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:42:46 UTC (rev 31) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:45:25 UTC (rev 32) @@ -126,15 +126,11 @@ use Data::Dumper; $sth->execute(); while ( my $row = $sth->fetchrow_hashref ) { - if ( $row->{'DEFINER'} eq 'JRUAN' ) { - push @fetched_tables, $row->{'TABNAME'}; - } - else { - warn $row->{'TABNAME'}; - } + push @fetched_tables, $row->{'TABNAME'}; + print Dumper($row); } warn Dumper(\@fetched_tables); - return @fetched_tables; + #return @fetched_tables; } sub get_handle { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 06:57:59
|
Revision: 33 http://treebase.svn.sourceforge.net/treebase/?rev=33&view=rev Author: rvos Date: 2009-06-11 06:57:57 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Changed fetchrow_hashref processing. Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:45:25 UTC (rev 32) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:57:57 UTC (rev 33) @@ -126,8 +126,9 @@ use Data::Dumper; $sth->execute(); while ( my $row = $sth->fetchrow_hashref ) { - push @fetched_tables, $row->{'TABNAME'}; - print Dumper($row); + if ( $row->{'TABNAME'} !~ /SYSIBM/ ) { + push @fetched_tables, $row->{'TABNAME'}; + } } warn Dumper(\@fetched_tables); #return @fetched_tables; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 06:58:22
|
Revision: 34 http://treebase.svn.sourceforge.net/treebase/?rev=34&view=rev Author: rvos Date: 2009-06-11 06:58:20 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Changed fetchrow_hashref processing. Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:57:57 UTC (rev 33) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:58:20 UTC (rev 34) @@ -126,7 +126,7 @@ use Data::Dumper; $sth->execute(); while ( my $row = $sth->fetchrow_hashref ) { - if ( $row->{'TABNAME'} !~ /SYSIBM/ ) { + if ( $row->{'DEFINER'} !~ /SYSIBM/ ) { push @fetched_tables, $row->{'TABNAME'}; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 07:00:30
|
Revision: 35 http://treebase.svn.sourceforge.net/treebase/?rev=35&view=rev Author: rvos Date: 2009-06-11 07:00:18 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Changed fetchrow_hashref processing. Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 06:58:20 UTC (rev 34) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 07:00:18 UTC (rev 35) @@ -126,7 +126,7 @@ use Data::Dumper; $sth->execute(); while ( my $row = $sth->fetchrow_hashref ) { - if ( $row->{'DEFINER'} !~ /SYSIBM/ ) { + if ( $row->{'DEFINER'} =~ /TBASE2/ ) { push @fetched_tables, $row->{'TABNAME'}; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 07:02:59
|
Revision: 36 http://treebase.svn.sourceforge.net/treebase/?rev=36&view=rev Author: rvos Date: 2009-06-11 07:02:58 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Changed fetchrow_hashref processing. Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 07:00:18 UTC (rev 35) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 07:02:58 UTC (rev 36) @@ -123,15 +123,13 @@ my $dbh = get_handle(); my $sth = $dbh->prepare('SELECT * FROM SYSCAT.TABLES'); my @fetched_tables; - use Data::Dumper; $sth->execute(); while ( my $row = $sth->fetchrow_hashref ) { if ( $row->{'DEFINER'} =~ /TBASE2/ ) { push @fetched_tables, $row->{'TABNAME'}; } } - warn Dumper(\@fetched_tables); - #return @fetched_tables; + return @fetched_tables; } sub get_handle { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 07:33:42
|
Revision: 37 http://treebase.svn.sourceforge.net/treebase/?rev=37&view=rev Author: rvos Date: 2009-06-11 07:33:41 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Changed SQL for fetching all tables Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 07:02:58 UTC (rev 36) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 07:33:41 UTC (rev 37) @@ -12,6 +12,7 @@ my $with_inserts = 1; # write insert statements my $with_creates = 0; # write create statements my $name_file_after_table = 0; # name output file after table +my $schema = 'TBASE2'; # name of schema to analyze # get command line options, see Getopt::Long GetOptions( @@ -23,9 +24,10 @@ 'pass=s' => \$ENV{'TREEBASE_DB_PASS'}, 'dsn=s' => \$ENV{'TREEBASE_DB_DSN'}, 'table=s' => \@tables, - 'help|?' => sub { pod2usage( '-verbose' => 0 ) }, # see Pod::Usage - 'man' => sub { pod2usage( '-verbose' => 1 ) }, # see Pod::Usage 'all' => sub { @tables = get_all_tables() }, + 'help|?' => sub { pod2usage( '-verbose' => 0 ) }, # see Pod::Usage + 'man' => sub { pod2usage( '-verbose' => 1 ) }, # see Pod::Usage + 'schema=s' => sub { @tables = get_all_tables(pop) }, 'file=s' => sub { my $file = pop; open my $fh, '>', $file @@ -52,82 +54,89 @@ '-msg' => 'Need at least one operation to write out (--inserts and/or --creates), aborting' ) unless $with_creates or $with_inserts; -# create database handle -my $dbh = get_handle(); - -for my $table ( @tables ) { - # only using these two functions once, so for clarity as to where they - # originate let's use the fully qualified names. - my @names = CIPRES::TreeBase::DBIUtil::get_colnames($dbh, $table); - my @types = CIPRES::TreeBase::DBIUtil::get_coltypes($dbh, $table); - - # instantiate a RecDumper object, which will format a row-as-array - # into an insert statement - my $dumper = CIPRES::TreeBase::RecDumper->new( - 'FIELDS' => \@names, - 'TYPES' => \@types, - 'TABLE' => $table - ) or die "Couldn't instantiate CIPRES::TreeBase::RecDumper"; +{ + # create database handle + my $dbh = get_handle(); - # give dumper the output handle to write to, i.e. either STDOUT, - # or a file specified on the command line, or the table name - if ( $name_file_after_table ) { - close $outhandle; - open my $fh, '>', "${table}.sql" or die $!; - $outhandle = $fh; - } - $dumper->set_output($outhandle); - - if ( $with_creates ) { - print $outhandle "CREATE TABLE $table;\n"; - } - - if ( $with_inserts ) { - # get all rows from $table - my $q = qq{select * from $table}; - my $sth = $dbh->prepare($q); - $sth->execute(); + for my $table ( @tables ) { + # only using these two functions once, so for clarity as to where they + # originate let's use the fully qualified names. + my @names = CIPRES::TreeBase::DBIUtil::get_colnames($dbh, $table); + my @types = CIPRES::TreeBase::DBIUtil::get_coltypes($dbh, $table); + + # instantiate a RecDumper object, which will format a row-as-array + # into an insert statement + my $dumper = CIPRES::TreeBase::RecDumper->new( + 'FIELDS' => \@names, + 'TYPES' => \@types, + 'TABLE' => $table + ) or die "Couldn't instantiate CIPRES::TreeBase::RecDumper"; - my $row; - - # if --progress is provided, print out progress counter - if ( $with_progress_meter ) { - my $count = 0; - while ( $row = $sth->fetchrow_arrayref ) { - ++$count; - $dumper->rec(@$row); - print STDERR "\r$count" if $count % 1000 == 0; - } - } - - # if --noprogress or default, just dump the records - else { - while ( $row = $sth->fetchrow_arrayref ) { - $dumper->rec(@$row); + # give dumper the output handle to write to, i.e. either STDOUT, + # or a file specified on the command line, or the table name + if ( $name_file_after_table ) { + close $outhandle; + open my $fh, '>', "${table}.sql" or die $!; + $outhandle = $fh; + } + $dumper->set_output($outhandle); + + if ( $with_creates ) { + print $outhandle "CREATE TABLE $table;\n"; + } + + if ( $with_inserts ) { + # get all rows from $table + my $q = qq{select * from $table}; + my $sth = $dbh->prepare($q); + $sth->execute(); + + my $row; + + # if --progress is provided, print out progress counter + if ( $with_progress_meter ) { + my $count = 0; + while ( $row = $sth->fetchrow_arrayref ) { + ++$count; + $dumper->rec(@$row); + print STDERR "\r$count" if $count % 1000 == 0; + } + } + + # if --noprogress or default, just dump the records + else { + while ( $row = $sth->fetchrow_arrayref ) { + $dumper->rec(@$row); + } } - } - - # finish the statement handler - $sth->finish(); - - # add line break if we're printing a progress counter - print STDERR "\n" if $with_progress_meter; - } + + # finish the statement handler + $sth->finish(); + + # add line break if we're printing a progress counter + print STDERR "\n" if $with_progress_meter; + } + } + + # disconnect from database + $dbh->disconnect; + exit 0; } -# disconnect from database -$dbh->disconnect; -exit 0; - sub get_all_tables { + my $schema_to_analyze = shift || $schema; my $dbh = get_handle(); - my $sth = $dbh->prepare('SELECT * FROM SYSCAT.TABLES'); + my $sth = $dbh->prepare(sprintf('list tables for schema %s', $schema_to_analyze)); my @fetched_tables; $sth->execute(); while ( my $row = $sth->fetchrow_hashref ) { - if ( $row->{'DEFINER'} =~ /TBASE2/ ) { - push @fetched_tables, $row->{'TABNAME'}; + use Data::Dumper; + if ( $row->{'DEFINER'} =~ /\Q$schema\E/ ) { + push @fetched_tables, $row->{'TABNAME'}; } + else { + print Dumper($row); + } } return @fetched_tables; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 07:37:06
|
Revision: 38 http://treebase.svn.sourceforge.net/treebase/?rev=38&view=rev Author: rvos Date: 2009-06-11 07:37:05 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Changed SQL for fetching all tables Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 07:33:41 UTC (rev 37) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 07:37:05 UTC (rev 38) @@ -126,7 +126,7 @@ sub get_all_tables { my $schema_to_analyze = shift || $schema; my $dbh = get_handle(); - my $sth = $dbh->prepare(sprintf('list tables for schema %s', $schema_to_analyze)); + my $sth = $dbh->prepare(sprintf(q{select tabname from syscat.tables where tabschema = '%s'}, $schema_to_analyze)); my @fetched_tables; $sth->execute(); while ( my $row = $sth->fetchrow_hashref ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 07:41:27
|
Revision: 39 http://treebase.svn.sourceforge.net/treebase/?rev=39&view=rev Author: rvos Date: 2009-06-11 07:41:26 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Changed SQL for fetching all tables Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 07:37:05 UTC (rev 38) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 07:41:26 UTC (rev 39) @@ -130,13 +130,7 @@ my @fetched_tables; $sth->execute(); while ( my $row = $sth->fetchrow_hashref ) { - use Data::Dumper; - if ( $row->{'DEFINER'} =~ /\Q$schema\E/ ) { - push @fetched_tables, $row->{'TABNAME'}; - } - else { - print Dumper($row); - } + push @fetched_tables, $row->{'TABNAME'}; } return @fetched_tables; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 07:54:15
|
Revision: 40 http://treebase.svn.sourceforge.net/treebase/?rev=40&view=rev Author: rvos Date: 2009-06-11 07:54:14 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Factored out insert statement printing to separate subroutine Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 07:41:26 UTC (rev 39) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 07:54:14 UTC (rev 40) @@ -81,40 +81,15 @@ } $dumper->set_output($outhandle); + # write create table statements if ( $with_creates ) { - print $outhandle "CREATE TABLE $table;\n"; + my $uc_table = uc $table; + print $outhandle "CREATE TABLE $uc_table;\n"; } + # write insert statements if ( $with_inserts ) { - # get all rows from $table - my $q = qq{select * from $table}; - my $sth = $dbh->prepare($q); - $sth->execute(); - - my $row; - - # if --progress is provided, print out progress counter - if ( $with_progress_meter ) { - my $count = 0; - while ( $row = $sth->fetchrow_arrayref ) { - ++$count; - $dumper->rec(@$row); - print STDERR "\r$count" if $count % 1000 == 0; - } - } - - # if --noprogress or default, just dump the records - else { - while ( $row = $sth->fetchrow_arrayref ) { - $dumper->rec(@$row); - } - } - - # finish the statement handler - $sth->finish(); - - # add line break if we're printing a progress counter - print STDERR "\n" if $with_progress_meter; + print_insert_statements ($dumper, $dbh, $table); } } @@ -141,3 +116,37 @@ $dbh->{'RaiseError'} = 1; return $dbh; } + +sub print_insert_statements { + my ( $dumper, $dbh, $table ) = @_; + + # get all rows from $table + my $q = qq{select * from $table}; + my $sth = $dbh->prepare($q); + $sth->execute(); + + my $row; + + # if --progress is provided, print out progress counter + if ($with_progress_meter) { + my $count = 0; + while ( $row = $sth->fetchrow_arrayref ) { + ++$count; + $dumper->rec(@$row); + print STDERR "\r$count" if $count % 1000 == 0; + } + } + + # if --noprogress or default, just dump the records + else { + while ( $row = $sth->fetchrow_arrayref ) { + $dumper->rec(@$row); + } + } + + # finish the statement handler + $sth->finish(); + + # add line break if we\'re printing a progress counter + print STDERR "\n" if $with_progress_meter; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-12 01:13:13
|
Revision: 44 http://treebase.svn.sourceforge.net/treebase/?rev=44&view=rev Author: rvos Date: 2009-06-12 01:13:12 +0000 (Fri, 12 Jun 2009) Log Message: ----------- Wrapped insert statement writing in eval{} block Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 18:04:40 UTC (rev 43) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-12 01:13:12 UTC (rev 44) @@ -16,136 +16,146 @@ # get command line options, see Getopt::Long GetOptions( - 'name-after-table' => \$name_file_after_table, - 'creates!' => \$with_creates, - 'inserts!' => \$with_inserts, - 'progress!' => \$with_progress_meter, - 'user=s' => \$ENV{'TREEBASE_DB_USER'}, - 'pass=s' => \$ENV{'TREEBASE_DB_PASS'}, - 'dsn=s' => \$ENV{'TREEBASE_DB_DSN'}, - 'table=s' => \@tables, - 'all' => sub { @tables = get_all_tables() }, - 'help|?' => sub { pod2usage( '-verbose' => 0 ) }, # see Pod::Usage - 'man' => sub { pod2usage( '-verbose' => 1 ) }, # see Pod::Usage - 'schema=s' => sub { @tables = get_all_tables(pop) }, - 'file=s' => sub { - my $file = pop; - open my $fh, '>', $file - or pod2usage( - '-msg' => "Couldn't write output file '$file': $!; aborting", - '-verbose' => 0, - '-exitval' => 1 - ); # see Pod::Usage - $outhandle = $fh; - }, + 'name-after-table' => \$name_file_after_table, + 'creates!' => \$with_creates, + 'inserts!' => \$with_inserts, + 'progress!' => \$with_progress_meter, + 'user=s' => \$ENV{'TREEBASE_DB_USER'}, + 'pass=s' => \$ENV{'TREEBASE_DB_PASS'}, + 'dsn=s' => \$ENV{'TREEBASE_DB_DSN'}, + 'table=s' => \@tables, + 'all' => sub { @tables = get_all_tables() }, + 'help|?' => sub { pod2usage( '-verbose' => 0 ) }, # see Pod::Usage + 'man' => sub { pod2usage( '-verbose' => 1 ) }, # see Pod::Usage + 'schema=s' => sub { @tables = get_all_tables(pop) }, + 'file=s' => sub { + my $file = pop; + open my $fh, '>', $file + or pod2usage( + '-msg' => "Couldn't write output file '$file': $!; aborting", + '-verbose' => 0, + '-exitval' => 1 + ); # see Pod::Usage + $outhandle = $fh; + }, ) || pod2usage( '-verbose' => 0, '-exitval' => 1 ); # need at least one table, see Pod::Usage pod2usage( - '-verbose' => 0, - '-exitval' => 1, - '-msg' => 'Need at least one table to dump, aborting' + '-verbose' => 0, + '-exitval' => 1, + '-msg' => 'Need at least one table to dump, aborting' ) unless @tables; # need at least one action, see Pod::Usage pod2usage( - '-verbose' => 0, - '-exitval' => 1, - '-msg' => 'Need at least one operation to write out (--inserts and/or --creates), aborting' + '-verbose' => 0, + '-exitval' => 1, + '-msg' => 'Need at least one operation to write out (--inserts and/or --creates), aborting' ) unless $with_creates or $with_inserts; { - # create database handle - my $dbh = get_handle(); - - for my $table ( @tables ) { - # only using these two functions once, so for clarity as to where they - # originate let's use the fully qualified names. - my @names = CIPRES::TreeBase::DBIUtil::get_colnames($dbh, $table); - my @types = CIPRES::TreeBase::DBIUtil::get_coltypes($dbh, $table); - - # instantiate a RecDumper object, which will format a row-as-array - # into an insert statement - my $dumper = CIPRES::TreeBase::RecDumper->new( - 'FIELDS' => \@names, - 'TYPES' => \@types, - 'TABLE' => $table - ) or die "Couldn't instantiate CIPRES::TreeBase::RecDumper"; - - # give dumper the output handle to write to, i.e. either STDOUT, - # or a file specified on the command line, or the table name - if ( $name_file_after_table ) { - close $outhandle; - open my $fh, '>', "${table}.sql" or die $!; - $outhandle = $fh; - } - $dumper->set_output($outhandle); - - # write create table statements - if ( $with_creates ) { - $dumper->dump_create; - } - - # write insert statements - if ( $with_inserts ) { - print_insert_statements ($dumper, $dbh, $table); - } - } - - # disconnect from database - $dbh->disconnect; - exit 0; + # create database handle + my $dbh = get_handle(); + + for my $table ( @tables ) { + # only using these two functions once, so for clarity as to where they + # originate let's use the fully qualified names. + my @names = CIPRES::TreeBase::DBIUtil::get_colnames($dbh, $table); + my @types = CIPRES::TreeBase::DBIUtil::get_coltypes($dbh, $table); + + # instantiate a RecDumper object, which will format a row-as-array + # into an insert statement + my $dumper = CIPRES::TreeBase::RecDumper->new( + 'FIELDS' => \@names, + 'TYPES' => \@types, + 'TABLE' => $table + ) or die "Couldn't instantiate CIPRES::TreeBase::RecDumper"; + + # give dumper the output handle to write to, i.e. either STDOUT, + # or a file specified on the command line, or the table name + if ( $name_file_after_table ) { + close $outhandle; + open my $fh, '>', "${table}.sql" or die $!; + $outhandle = $fh; + } + $dumper->set_output($outhandle); + + # write create table statements + if ( $with_creates ) { + $dumper->dump_create; + } + + # write insert statements + if ( $with_inserts ) { + eval { + print_insert_statements ($dumper, $dbh, $table) + }; + if ( $@ ) { + print STDERR "Table ${table} failed?! Sorry...\n"; + } + } + } + + # disconnect from database + $dbh->disconnect; + exit 0; } sub get_all_tables { - my $schema_to_analyze = shift || $schema; - my $dbh = get_handle(); - my $sth = $dbh->prepare(sprintf(q{select tabname from syscat.tables where tabschema = '%s'}, $schema_to_analyze)); - my @fetched_tables; - $sth->execute(); - while ( my $row = $sth->fetchrow_hashref ) { - push @fetched_tables, $row->{'TABNAME'}; - } - return @fetched_tables; + my $schema_to_analyze = shift || $schema; + my $dbh = get_handle(); + my $sth = $dbh->prepare( + sprintf( + q{select tabname from syscat.tables where tabschema = '%s'}, + $schema_to_analyze + ) + ); + my @fetched_tables; + $sth->execute(); + while ( my $row = $sth->fetchrow_hashref ) { + push @fetched_tables, $row->{'TABNAME'}; + } + return @fetched_tables; } sub get_handle { - my $dbh = CIPRES::TreeBase::DBIUtil->dbh - or die "Couldn't connect to database: " . DBI->errstr; - $dbh->{'RaiseError'} = 1; - return $dbh; + my $dbh = CIPRES::TreeBase::DBIUtil->dbh + or die "Couldn't connect to database: " . DBI->errstr; + $dbh->{'RaiseError'} = 1; + return $dbh; } sub print_insert_statements { - my ( $dumper, $dbh, $table ) = @_; + my ( $dumper, $dbh, $table ) = @_; - # get all rows from $table - my $q = qq{select * from $table}; - my $sth = $dbh->prepare($q); - $sth->execute(); + # get all rows from $table + my $q = qq{select * from $table}; + my $sth = $dbh->prepare($q); + $sth->execute(); - my $row; + my $row; - # if --progress is provided, print out progress counter - if ($with_progress_meter) { - my $count = 0; - while ( $row = $sth->fetchrow_arrayref ) { - ++$count; - $dumper->rec(@$row); - print STDERR "\r$count" if $count % 1000 == 0; - } - } + # if --progress is provided, print out progress counter + if ($with_progress_meter) { + my $count = 0; + while ( $row = $sth->fetchrow_arrayref ) { + ++$count; + $dumper->rec(@$row); + print STDERR "\r$count" if $count % 1000 == 0; + } + } - # if --noprogress or default, just dump the records - else { - while ( $row = $sth->fetchrow_arrayref ) { - $dumper->rec(@$row); - } - } + # if --noprogress or default, just dump the records + else { + while ( $row = $sth->fetchrow_arrayref ) { + $dumper->rec(@$row); + } + } - # finish the statement handler - $sth->finish(); + # finish the statement handler + $sth->finish(); - # add line break if we\'re printing a progress counter - print STDERR "\n" if $with_progress_meter; + # add line break if we\'re printing a progress counter + print STDERR "\n" if $with_progress_meter; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-12 02:00:43
|
Revision: 45 http://treebase.svn.sourceforge.net/treebase/?rev=45&view=rev Author: rvos Date: 2009-06-12 01:37:07 +0000 (Fri, 12 Jun 2009) Log Message: ----------- Added --zip flag to sqldump Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-12 01:13:12 UTC (rev 44) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-12 01:37:07 UTC (rev 45) @@ -13,6 +13,7 @@ my $with_creates = 0; # write create statements my $name_file_after_table = 0; # name output file after table my $schema = 'TBASE2'; # name of schema to analyze +my $zip = 0; # zip output # get command line options, see Getopt::Long GetOptions( @@ -24,6 +25,7 @@ 'pass=s' => \$ENV{'TREEBASE_DB_PASS'}, 'dsn=s' => \$ENV{'TREEBASE_DB_DSN'}, 'table=s' => \@tables, + 'zip' => \$zip, 'all' => sub { @tables = get_all_tables() }, 'help|?' => sub { pod2usage( '-verbose' => 0 ) }, # see Pod::Usage 'man' => sub { pod2usage( '-verbose' => 1 ) }, # see Pod::Usage @@ -73,12 +75,18 @@ ) or die "Couldn't instantiate CIPRES::TreeBase::RecDumper"; # give dumper the output handle to write to, i.e. either STDOUT, - # or a file specified on the command line, or the table name + # or a file specified on the command line, or the table name... if ( $name_file_after_table ) { close $outhandle; open my $fh, '>', "${table}.sql" or die $!; $outhandle = $fh; } + # ...or a compressed file + elsif ( $zip ) { + close $outhandle; + open my $ziph, "| gzip -9 > ${table}.gz" or die $!; + $outhandle = $ziph; + } $dumper->set_output($outhandle); # write create table statements This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-12 05:20:01
|
Revision: 46 http://treebase.svn.sourceforge.net/treebase/?rev=46&view=rev Author: rvos Date: 2009-06-12 05:19:59 +0000 (Fri, 12 Jun 2009) Log Message: ----------- Added more diagnostics to failed () table dumps: Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-12 01:37:07 UTC (rev 45) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-12 05:19:59 UTC (rev 46) @@ -100,7 +100,7 @@ print_insert_statements ($dumper, $dbh, $table) }; if ( $@ ) { - print STDERR "Table ${table} failed?! Sorry...\n"; + print STDERR "Table ${table} failed: $@\n"; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mjd...@us...> - 2009-06-12 07:06:20
|
Revision: 49 http://treebase.svn.sourceforge.net/treebase/?rev=49&view=rev Author: mjdominus Date: 2009-06-12 07:04:33 +0000 (Fri, 12 Jun 2009) Log Message: ----------- Added test mode Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-12 07:02:15 UTC (rev 48) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-12 07:04:33 UTC (rev 49) @@ -14,6 +14,7 @@ my $name_file_after_table = 0; # name output file after table my $schema = 'TBASE2'; # name of schema to analyze my $zip = 0; # zip output +my $test = 0; # test run: delete produced files # get command line options, see Getopt::Long GetOptions( @@ -26,6 +27,7 @@ 'dsn=s' => \$ENV{'TREEBASE_DB_DSN'}, 'table=s' => \@tables, 'zip' => \$zip, + 'test' => \$test, 'all' => sub { @tables = get_all_tables() }, 'help|?' => sub { pod2usage( '-verbose' => 0 ) }, # see Pod::Usage 'man' => sub { pod2usage( '-verbose' => 1 ) }, # see Pod::Usage @@ -97,10 +99,18 @@ # write insert statements if ( $with_inserts ) { eval { - print_insert_statements ($dumper, $dbh, $table) + print_insert_statements ($dumper, $dbh, $table); + if ( $test ) { + for ( qw(gz sql) ) { + if ( -e "${table}.${_}" ) { + unlink "${table}.${_}"; + } + } + } }; if ( $@ ) { print STDERR "Table ${table} failed: $@\n"; + $dumper->dump_create; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |