in reply to Re^3: Threads and multiple DBI connections
in thread Threads and multiple DBI connections
And $dbh->errstr is -->my $dbh = DBIx::Threaded->connect("DBI:mysql:database=$database;host=$ +host", $user, $password); DBIx::Threaded->dbix_threaded_create_pool(10); my $sth = $dbh->prepare("SELECT id,domain,DATE(created) FROM domain_li +st"); $sth->execute(); my $counter = 0; while (my @row = $sth->fetchrow_array()) { my $id = $row[0]; my $domain = $row[1]; my $created = $row[2]; next unless $row[0..3]; my $thr = threads->create(mx_lookup,$id,$domain,$created,$dbh) unl +ess $counter >= $thread_no; $thr->detach && $counter++ if $thr; } $sth->finish(); sub mx_lookup { my $id = shift; my $domain = shift; my $date_c = shift; my @date_c = split /-/, $date_c; my $delta = Delta_Days(@date_c,@date); my %emails_in; my %emails_out; if ($delta <= 30) { my @mx = mx($domain); #add multiple mxs support here my $mx_count = @mx; my $mx = $mx[0]->exchange; #find the last change for the given domain my $sth = $dbh->prepare("select max(id),domain_id,changed_from +,changed_to,date from mx_history where domain_id=?"); #this is where +the script fails $sth->execute($id); my @row = $sth->fetchrow_array(); $sth->finish(); } }
seems like that the $dbh handle isn't conected at all...Thread 43 terminated abnormally: Error:Unexpected db_prepare request: +must be connected to do that.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Threads and multiple DBI connections
by BrowserUk (Patriarch) on Nov 01, 2010 at 22:02 UTC | |
by Anonymous Monk on Nov 02, 2010 at 11:17 UTC |