Gtk2::Ex::Threads::DBI

Achieving asynchronous DBI like functionality for gtk2-perl applications using perl ithreads
Download

Gtk2::Ex::Threads::DBI Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Ofey Aikon
  • Publisher web site:
  • http://search.cpan.org/~ofeyaikon/

Gtk2::Ex::Threads::DBI Tags


Gtk2::Ex::Threads::DBI Description

Achieving asynchronous DBI like functionality for gtk2-perl applications using perl ithreads Gtk2::Ex::Threads::DBI is a Perl module that will help you achieve this functionality through the use of perl ithreads. An asynchronous DBI like functionality is achieved through using callbacks from a separate thread.SYNOPSIS use Glib qw(TRUE FALSE); use Gtk2 qw/-init -threads-init/; use Gtk2::Ex::Threads::DBI; use Storable qw(freeze thaw); my $mythread = Gtk2::Ex::Threads::DBI->new( { dsn => 'DBI:mysql:test:localhost', user => 'root', passwd => 'test', attr => { RaiseError => 1, AutoCommit => 0 } }); my $query = $mythread->register_query(undef, \&call_sql, \&call_back); $mythread->start(); my $button = Gtk2::Button->new('fetch data from table using pattern'); $button->signal_connect (clicked => sub { my $pattern = $entry->get_text(); #Get the pattern $query->execute(); } ); # This function gets called from inside the thread sub call_sql { my ($dbh, $sqlparams) = @_; my $params = thaw $sqlparams; my $sth = $dbh->prepare(qq{ # my complicated long query that takes a long time to complete select * from xxx where yyy like ? limit 1000 }); $sth->execute('%'.$params->.'%'); my @result_array; while (my @ary = $sth->fetchrow_array()) { push @result_array, \@ary; } return \@result_array; } # This function gets called from inside the thread after sql execution sub call_back { my ($self, $result_array) = @_; @{$slist->{data}} = (); #We'll populate a SimpleList with the data foreach my $x (thaw $result_array) { push @{$slist->{data}}, @$x; } } Requirements: · Perl


Gtk2::Ex::Threads::DBI Related Software