sekimura's Journal
http://use.perl.org/~sekimura/journal/
sekimura's use Perl Journalen-ususe Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners.2012-01-25T02:43:33+00:00pudgepudge@perl.orgTechnologyhourly11970-01-01T00:00+00:00sekimura's Journalhttp://use.perl.org/images/topics/useperl.gif
http://use.perl.org/~sekimura/journal/
DBD::Util::Bundle
http://use.perl.org/~sekimura/journal/33029?from=rss
<tt>package DBD::Util::Bundle;<br><br>=pod<br><br> my $dbh0 = DBI->connect( 'dbi:mysql:database=myfoo', 'doh' );<br> my $dbh1 = DBI->connect( 'dbi:Pg:dbname=pgfoo', 'ugh' );<br><br> my $bbh = DBD::Util::Bundle->new(dbh_stack => [$dbh0, $dbh1]);<br><br> $bbh->prepare('SELECT * FROM bookshelf WHERE book_id >= 10');<br> $bbh->execute();<br><br> use Data::Dumper;<br> use YAML;<br> while ( my ($aref0, $aref1) = $bbh->fetchrow_arrayref ) {<br> my ($dump0, $dmup1) = map { YAML::Dump $_ } ($aref0, $aref1);<br> print "SRC $dump0 DST $dump1" if $dump0 ne $dump1;<br> }<br><br>=cut<br><br>sub new {<br> my $class = shift;<br> my %args = @_;<br> my $self = bless {}, $class;<br> $self->{dbh_stack} = $args{dbh_stack};<br> return $self;<br>}<br><br>sub prepare {<br> my $self = shift;<br> my ( @args ) = @_;<br> my @ret;<br> for my $dbh (@{$self->{dbh_stack}}) {<br> push @ret, $dbh->prepare(@args);<br> }<br> $self->{sth_stack} = \@ret;<br> return @ret;<br>}<br><br>sub execute {<br> my $self = shift;<br> my ( @args ) = @_;<br> my @ret;<br> for my $sth (@{$self->{sth_stack}}) {<br> push @ret, $sth->execute(@args);<br> }<br> return @ret;<br>}<br><br>sub fetchrow_arrayref {<br> my $self = shift;<br> my @ret;<br> for my $sth (@{$self->{sth_stack}}) {<br> my $aref = $sth->fetchrow_arrayref or return;<br> push @ret, $aref;<br> }<br> return @ret;<br>}<br></tt>sekimura2007-04-19T06:18:05+00:00journala simple SQL client
http://use.perl.org/~sekimura/journal/32985?from=rss
<p>now I'm writing a simple SQL client that can connect multiple database servers. for some reasons I need to connect to MySQL and PostgreSQL. </p><p>using "screen" and "mysql + psql" works but sometimes I wanna share a term history on each SQL clients. </p><p>so, I'm doing it. Term::Shell and Text::ASCIITable rock.</p><p>TODO: handle '*', '%' and more SQL special chars.</p><p> <strong>UPDATE</strong> found DBI::Shell but it can't handle multiple DBI connections.</p>sekimura2007-04-13T17:07:30+00:00journal