Hi,

You can use DBIx :: Connector to ping automatically and not lose the 
connection.

El miércoles, 12 de marzo de 2014 06:25:54 UTC+1, Sergey escribió:
>
> This could be connection timeout. If this is case, use Reconnect plugin.
>
> -- HtH, Sergey (from mobile)
> 12 марта 2014 г. 4:32 пользователь "Neil Watson" 
> <[email protected]<javascript:>> 
> написал:
>
>> Howdy,
>>
>> I'm learning and prototyping with mojo lite. I'm getting a db connection
>> error but I don't know why.
>>
>> Error:
>> DBD::Pg::st execute failed: Cannot call execute on a disconnected
>> database handle at DReport.pl line 24. 
>> Line 24 is at the end of the excerpt below. There was no die from
>> DBI->connect yet the error indicates no connection. I have another,
>> unrelated, script that uses the same connect code and credentials and it
>> works just fine. What have I done wrong?
>>
>> use Mojolicious::Lite;
>> use DBI;
>>
>> my $db_name = "postgres";
>> my $db_user = "postgres";
>> my $db_pass = "";
>> my $db_host = "127.0.0.1";
>> my $table   = "cf_status_log";
>>
>> my $dbh = DBI->connect(
>>       "DBI:Pg:dbname=$db_name; host=$db_host",
>>       "$db_user", "$db_pass",
>>       { RaiseError => 1 }
>> ) or die "Could not connec to database";
>>
>> helper db => sub { $dbh };
>>
>> helper inventory => sub
>> {
>>    my $self = shift;
>>    my $result = eval { $self->db->prepare( "SELECT * FROM 
>> dr_inventory_classes" ) };
>>    my $number_of_records = $result->execute();   # <<<< Line 24
>>
>> -- 
>> Neil Watson
>> Linux/UNIX Consultant
>> http://watson-wilson.ca
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Mojolicious" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/mojolicious.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to