Alberto Luaces <alua...@udc.es> writes:

> Hi,
>
> I stumped over a problem when learning to use DBIx::Class.  I had a typo
> on the filename holding the database, but no exception was thrown until
> I wanted to retrieve some results, which was not intuitive for me.  How
> do you check for a successful connection?

First of all, you never need to do "or die ..." with DBIx::Class
operations, since they always throw exceptions on error.

Sencondly, DBIx::Class only hits the database when it absolutely has to,
e.g. to fetch restults.  This includes the initial connection.  However,
you can force it to connect early by calling

   $schema->storage->ensure_connected;

Which will throw an exception if it fails to connect.

-- 
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
 the consequences of."                              -- Skud's Meta-Law


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to