You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
(1) |
Apr
(14) |
May
(36) |
Jun
(148) |
Jul
(33) |
Aug
(2) |
Sep
(17) |
Oct
(42) |
Nov
(137) |
Dec
(88) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(89) |
Feb
(80) |
Mar
(217) |
Apr
(76) |
May
(5) |
Jun
(39) |
Jul
(35) |
Aug
(4) |
Sep
(7) |
Oct
(14) |
Nov
(12) |
Dec
(9) |
2011 |
Jan
(6) |
Feb
(4) |
Mar
(11) |
Apr
(55) |
May
(90) |
Jun
(39) |
Jul
(15) |
Aug
(15) |
Sep
(23) |
Oct
(12) |
Nov
(17) |
Dec
(20) |
2012 |
Jan
(22) |
Feb
(63) |
Mar
|
Apr
(1) |
May
(6) |
Jun
(3) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
(3) |
Feb
(6) |
Mar
|
Apr
|
May
|
Jun
(4) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
(7) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <rv...@us...> - 2009-06-12 06:14:27
|
Revision: 47 http://treebase.svn.sourceforge.net/treebase/?rev=47&view=rev Author: rvos Date: 2009-06-12 06:14:21 +0000 (Fri, 12 Jun 2009) Log Message: ----------- Added CLOB handling Modified Paths: -------------- trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm Modified: trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm =================================================================== --- trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm 2009-06-12 05:19:59 UTC (rev 46) +++ trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm 2009-06-12 06:14:21 UTC (rev 47) @@ -65,7 +65,7 @@ local *_ = \$d[$i]; $_ = "NULL", next unless defined; - if ($t eq "CHAR" || $t eq "VARCHAR") { + if ($t eq "CHAR" || $t eq "VARCHAR" || $t eq 'CLOB') { s/'/''/g; $_ = "'$_'"; } 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: <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 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: <mjd...@us...> - 2009-06-11 18:05:45
|
Revision: 43 http://treebase.svn.sourceforge.net/treebase/?rev=43&view=rev Author: mjdominus Date: 2009-06-11 18:04:40 +0000 (Thu, 11 Jun 2009) Log Message: ----------- clean up messy quotation marks, remove unused comment Modified Paths: -------------- trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm Modified: trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm =================================================================== --- trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm 2009-06-11 08:37:48 UTC (rev 42) +++ trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm 2009-06-11 18:04:40 UTC (rev 43) @@ -1,7 +1,7 @@ package CIPRES::TreeBase::RecDumper; use Carp 'croak'; -# LOB fields should be removed from fieldlist and handled separately +# XXX LOB fields should be removed from fieldlist and handled separately sub new { my $class = shift; my %arg = @_; @@ -12,7 +12,7 @@ my $self = { 'F' => \@fieldnames, 'X' => $X, - 'N' => '"'.$tn.'"', + 'N' => $tn, 'T' => $ct }; bless $self => $class; @@ -27,9 +27,8 @@ sub _initialize { my $self = shift; - my $fieldlist = join ", ", map { "\"$_\"" } @{$self->{F}}; - # Need to escape certain field names here - $self->{'PREFIX'} = qq{INSERT INTO $self->{N} ($fieldlist) VALUES (}; + my $fieldlist = join ", ", map qq{"$_"}, @{$self->{F}}; + $self->{'PREFIX'} = qq{INSERT INTO "$self->{N}" ($fieldlist) VALUES (}; $self->{'SUFFIX'} = qq{);\n}; # XXX added closing semicolon return; } @@ -52,7 +51,7 @@ # Format metadata into a create statement and return (or write) the result sub dump_create { - my $create = 'CREATE TABLE ' . $self->{'N'} . ";\n"; + my $create = qq{CREATE TABLE "$self->{'N'}";\n}; return print {$self->{'OUT'}} $create if $self->{'OUT'}; return $create; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 08:37:54
|
Revision: 42 http://treebase.svn.sourceforge.net/treebase/?rev=42&view=rev Author: rvos Date: 2009-06-11 08:37:48 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Added pg upper case escaping Modified Paths: -------------- trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm Modified: trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm =================================================================== --- trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm 2009-06-11 08:21:24 UTC (rev 41) +++ trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm 2009-06-11 08:37:48 UTC (rev 42) @@ -12,7 +12,7 @@ my $self = { 'F' => \@fieldnames, 'X' => $X, - 'N' => $tn, + 'N' => '"'.$tn.'"', 'T' => $ct }; bless $self => $class; @@ -27,7 +27,7 @@ sub _initialize { my $self = shift; - my $fieldlist = join ", ", @{$self->{F}}; + my $fieldlist = join ", ", map { "\"$_\"" } @{$self->{F}}; # Need to escape certain field names here $self->{'PREFIX'} = qq{INSERT INTO $self->{N} ($fieldlist) VALUES (}; $self->{'SUFFIX'} = qq{);\n}; # XXX added closing semicolon This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-11 08:21:27
|
Revision: 41 http://treebase.svn.sourceforge.net/treebase/?rev=41&view=rev Author: rvos Date: 2009-06-11 08:21:24 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Factored CREATE statement writing out to RecDumper.pm Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 07:54:14 UTC (rev 40) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-11 08:21:24 UTC (rev 41) @@ -83,8 +83,7 @@ # write create table statements if ( $with_creates ) { - my $uc_table = uc $table; - print $outhandle "CREATE TABLE $uc_table;\n"; + $dumper->dump_create; } # write insert statements Modified: trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm =================================================================== --- trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm 2009-06-11 07:54:14 UTC (rev 40) +++ trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm 2009-06-11 08:21:24 UTC (rev 41) @@ -50,6 +50,13 @@ return $insert; } +# Format metadata into a create statement and return (or write) the result +sub dump_create { + my $create = 'CREATE TABLE ' . $self->{'N'} . ";\n"; + return print {$self->{'OUT'}} $create if $self->{'OUT'}; + return $create; +} + # XXX UNFINISHED !!!! sub quote_data { my $self = shift; 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-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: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: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: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: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 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 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: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: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: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: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: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: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: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: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: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: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. |